- 安裝Supervisor(具體參考官網文檔)
easy_install supervisor
- 配置
[include]
files = /etc/supervisord.conf.d/*.conf(放置自定義服務配置的目錄官脓,文件夾可以自己創(chuàng)建)
[program:beepkg]
directory = /opt/app/beepkg
command = /opt/app/beepkg/api
autostart = true
startsecs = 5
user = root
redirect_stderr = true
stdout_logfile = /tmp/beepkg.log
- 啟動Supervisor服務
supervisord -c /etc/supervisord.conf
- 常用命令
supervisorctl status
supervisorctl stop tomcat
supervisorctl start tomcat
supervisorctl restart tomcat
supervisorctl reread
supervisorctl update
- 常見的問題及解決辦法
【1】unix:///tmp/supervisor.sock no such file
解決辦法:
(1)關閉所有supervisor服務(supervisorctl stop all)
(2)殺掉supervisor進程(kill -9 pid,具體pid可以到/tmp/supervisord.pid中查看,或者采用ps -ef | grep supervisor命令查看)分冈。
image.png
(3)到/etc/supervisord.conf中修改supervisor.sock的存放目錄(因為 linux 系統(tǒng)會不定期的清理 tmp 文件夾钧嘶,注意塘慕,此處需要修改兩處)洋只,然后重新啟動服務(supervisord -c /etc/supervisord.conf
)割笙。
【2】supervisor.sock refused connection
解決辦法:重啟服務。
- 其他
【1】可以在/etc/supervisor.conf文件中指定服務的啟動用戶及密碼
image.png