Systemctl 可以重新启动已经死亡的进程,还是 Supervisor 进来的地方?

Mat*_*sen 9 systemd supervisord

根据我的研究,Supervisor 和 Systemctl 似乎不能互换,但是它们具有重叠的功能;值得注意的是,它们都可以用于启动其他进程。但是,Supervisor 能够重新启动因任何原因而死亡的应用程序。我找不到任何表明 systemctl 能够做到这一点的东西。

Systemctl 可以用来重启已经死掉的进程吗?

此外,在我看来,大多数人会,例如,将 Postgres 和 Nginx 或 Apache 添加到 Systemctl,但会将他们的应用程序添加到主管。为什么是这样?他们不应该将所有这些都添加到 Supervisor 中,以便 Supervisor 在他们死后可以重新启动它们吗?

Ste*_*ris 14

systemctl通常是用于配置和控制的命令systemd

systemd单元可以包含有关进程终止时要做什么的指令。

例如,对于 RedHat 7,默认的 rsyslogd 安装包含一个单元文件,该文件具有:

[Service]
....
Restart=on-failure
Run Code Online (Sandbox Code Playgroud)

作为其中的一部分。

来自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. 
Run Code Online (Sandbox Code Playgroud)

systemd它相对较新,人们可能不了解它的功能。此外,他们可能不知道允许用户做自己的事情的用户单元。

supervisord 是一个更古老的程序,所以人们可能更清楚这一点,因为它已经使用了十年并且认为没有任何改变的必要。