Linux安装supervisor

安装supervisor。

pip install supervisor。

产生配置文件。

echo_supervisord_conf > /usr/local/etc/supervisord.conf。

supervisor服务启动脚本。

vim /lib/systemd/system/supervisord.service 。
supervisord开机自启动脚本(各版本系统):https://github.com/Supervisor/initscripts 。
'''
# supervisord service for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /usr/local/etc/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

'''

自启动脚本都能够添加到systemctl自启动服务

systemctl enable supervisord.service
systemctl start/restart/stop supervisor.service

守护进程

supervisord启动后,其自身就会蜕变成一个守护进程,然后,它会根据用户的配置文件,根据用户启动配置启动用户需要的进程,而用户配置的进程就变成了supervisord的子进程,如果子进程发生了什么意外导致退出,supervisord进程会收到子进程挂掉的消息,然后重新启动子进程,这样就是守护-守护进程-的进程,由supervisor替管理员管理服务进程的生命周。事实上,用supervisor启动守护进程,某种程度上有点像nohup的方法,把自身非守护进程的进程当作守护进程再运行,所以如果某个程序本身就是默认以守护进程的方式运行的,就会出问题。



原文链接

猜你喜欢

转载自blog.csdn.net/qswm_18301240090/article/details/78204454
今日推荐