閱讀415 返回首頁    go 阿裏雲 go 技術社區[雲棲]


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的方法,把自身非守護進程的進程當作守護進程再運行,所以如果某個程序本身就是默認以守護進程的方式運行的,就會出問題。

最後更新:2017-10-02 21:08:19

  上一篇:go  Win10係統下安裝ubuntu係統
  下一篇:go  Linux安裝桌麵gnome