ITSkillsCenter
Développement Web

Créer un service systemd : tutoriel 2026

1 دقائق للقراءة

Tutoriel pour créer un service systemd robuste pour vos applications en 2026.

Voir notre guide systemd timers.

Service simple

# /etc/systemd/system/myapp.service
[Unit]
Description=My Bun API
After=network.target postgresql.service
Requires=postgresql.service

[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=/opt/myapp/.env
ExecStart=/usr/local/bin/bun run start
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal

# Hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/myapp/uploads
ProtectKernelTunables=true
RestrictAddressFamilies=AF_INET AF_INET6
LockPersonality=true

# Limits
MemoryMax=512M
CPUQuota=80%

[Install]
WantedBy=multi-user.target

Activer

systemctl daemon-reload
systemctl enable --now myapp
systemctl status myapp
journalctl -u myapp -f

Type=oneshot pour scripts

Pour un script qui finit après exécution (backup, cron-like) : Type=oneshot + RemainAfterExit=no.

Type=notify pour app moderne

Si votre app supporte sd_notify (Coolify, Caddy, Postgres) : Type=notify. systemd considère le service « actif » seulement quand l’app envoie son ready signal.

Pour aller plus loin

Besoin d'un site web ?

Confiez-nous la Création de Votre Site Web

Site vitrine, e-commerce ou application web — nous transformons votre vision en réalité digitale. Accompagnement personnalisé de A à Z.

À partir de 250.000 FCFA
Parlons de Votre Projet
Publicité