Can Systemctl restart processes that have died, or is that where Supervisor comes in?

14,903

systemctl is typically a command used to configure and control systemd.

A systemd unit can include instructions on what to do if a process terminates.

For example, with RedHat 7 the default rsyslogd install includes a unit file that has:

[Service]
....
Restart=on-failure

as part of it.

From man systemd.service:

   Restart=
       Configures whether the service shall be restarted when the service
       process exits, is killed, or a timeout is reached. The service
       process may be the main service process, but it may also be one of
       the processes specified with ExecStartPre=, ExecStartPost=,
       ExecStop=, ExecStopPost=, or ExecReload=. When the death of the
       process is a result of systemd operation (e.g. service stop or
       restart), the service will not be restarted. Timeouts include
       missing the watchdog "keep-alive ping" deadline and a service
       start, reload, and stop operation timeouts.

       Takes one of no, on-success, on-failure, on-abnormal, on-watchdog,
       on-abort, or always. If set to no (the default), the service will
       not be restarted. 

systemd is relatively new and people may not be aware of its capabilities. Further they may not be aware of user units, that allow users to do their own stuff.

supervisord is a much much older program, so people may be more aware of that, of have been using it for a decade and don't see any need to change.

Share:
14,903

Related videos on Youtube

Matthew Moisen
Author by

Matthew Moisen

Backend engineer specializing in Python and RDBMS.

Updated on September 18, 2022

Comments

  • Matthew Moisen
    Matthew Moisen over 1 year

    From my research, it would appear that Supervisor and Systemctl are not interchangeable, however they have overlapping functions; notably, they both can be used to start other processes. However, Supervisor is capable of restarting an application that died for whatever reason. I cannot find anything that suggests systemctl is capable of this.

    Can Systemctl be used to restart a process that has died?

    Moreover, it seems to me that most people will, for example, add Postgres and Nginx or Apache to Systemctl, but will add their application to supervisor. Why is this? Shouldn't they add all of these to Supervisor instead, so that Supervisor can restart them if they died?