This article states the following:
systemdwhat command it should run to launch our app. Then,
systemdunder what conditions it should restart the app if it sees that it has died. The
on-failurevalue is likely what you will want. Using this, the app will NOT restart if it goes away “cleanly”. Going away “cleanly” means that it either exits by itself with an exit value of
0, or it gets killed with a “clean” signal, such as the default signal sent by the
killcommand. Basically, if our app goes away because we want it to, then
systemdwill leave it turned off. However, if it goes away for any other reason (an unhandled exception crashes the app, for example), then
systemdwill immediately restart it for us. If you want it to restart no matter what, change the value from
systemd config for nginx as restart=always:
[Service] Type=simple WorkingDirectory=<%= dir %> User=<%= user %> Environment="NODE_ENV=<%= environment %>" ExecStart=<%= ghost_exec_path %> run Restart=always <================================
In fact, as the article explains, I just tried to run a small experiment. I found a ghost process PID and killed it with
kill command. Within a few seconds, the process was restarted by
systemd although it wasn’t failure, it was a
clean process stop.
Is that intentional? What’s the rationale behind it? Thanks!