From 0505a48f44f929ab13b26dd4abc50fc49637172a Mon Sep 17 00:00:00 2001 From: jlecour Date: Tue, 25 Jul 2017 23:48:37 +0200 Subject: [PATCH] Exemple pour systemd+forever+node.js --- HowtoSystemd.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/HowtoSystemd.md b/HowtoSystemd.md index 8e38d786..4706a805 100644 --- a/HowtoSystemd.md +++ b/HowtoSystemd.md @@ -462,4 +462,27 @@ systemd prend en compte les scripts dans `/etc/init.d/` : * les scripts « classiques » sont pris en compte si il n'existe pas d'unité systemd avec le même nom (sa description commence alors par **LSB:**) * certains scripts sont juste là par compatibilité afin de pouvoir faire `/etc/init.d/foo start/stop/restart/status` mais c'est en fait l'unité systemd qui est prise en compte +## Exemples d'unités +### Process Node.js géré via forever + +*forever* est lui-même un gestionnaire de process, mais dans certains cas c'ets pertinent d'empiler les 2 gestionnaires. Voici un exemple fonctionnel (qu'on pourrait vouloir transformer en unité "user") : + +~~~ +# /etc/systemd/system/foo_chat.service +[Unit] +Description=Node.js process for Foo chat +After=network.target + +[Service] +ExecStart=/usr/local/bin/forever start --pidFile /home/foo/www/foo.pid -o /home/foo/www/log/out.log -e /home/foo/www/log/err.log /home/foo/www/bin/www +ExecStop=/usr/local/bin/forever stop /home/foo/www/bin/www +PIDFile=/home/foo/www/foo.pid +Type=forking +LimitNOFILE=4096 +User=nod +Restart=always + +[Install] +WantedBy=default.target +~~~ \ No newline at end of file