Supervisor部署
Supervisor是用Python
開(kāi)發(fā)的一個(gè)client/server
服務(wù),是Linux/Unix
系統(tǒng)下的一個(gè)進(jìn)程管理工具,不支持Windows
系統(tǒng)。很方便的監(jiān)聽(tīng)、啟動(dòng)、停止、重啟一個(gè)或多個(gè)進(jìn)程。用Supervisor
管理的進(jìn)程,當(dāng)一個(gè)進(jìn)程意外被Kill
,會(huì)自動(dòng)將它重新拉起,不需要開(kāi)發(fā)者自己編寫(xiě)shell
進(jìn)行進(jìn)程管理來(lái)維護(hù)自己的服務(wù)。
安裝Supervisor
采用Ubuntu
系統(tǒng)下的安裝方式進(jìn)行演示:
apt-get -y install supervisor
創(chuàng)建配置文件
vim /etc/supervisor/conf.d/easyswoole.conf
文件內(nèi)容如下:
# 設(shè)置應(yīng)用名稱為easyswoole
[program:easyswoole]
# 設(shè)置運(yùn)行目錄
directory=/data/wwwroot/EasySwoole3.7.x
# 項(xiàng)目的啟動(dòng)命令
command=php easyswoole.php server start
# 設(shè)置用戶來(lái)運(yùn)行該進(jìn)程
user=www-data
# 是否隨著supervisor啟動(dòng)時(shí) 自動(dòng)啟動(dòng)該應(yīng)用
autostart=true
# 進(jìn)程退出 是否自動(dòng)重啟進(jìn)程
autorestart=true
# 進(jìn)程啟動(dòng)多少秒之后被認(rèn)為是啟動(dòng)成功 默認(rèn)1s
startsecs=1
# 失敗最大嘗試次數(shù) 默認(rèn)3
startretries=3
# stderr
stderr_logfile=/data/wwwlog/easyswoole-stderr.log
# stdout
stdout_logfile=/data/wwwlog/easyswoole-stdout.log
啟動(dòng)Supervisor
service supervisor start
Supervisorctl
啟動(dòng)EasySwoole應(yīng)用
supervisorctl start easyswoole
停止EasySwoole應(yīng)用
supervisorctl stop easyswoole
重啟EasySwoole應(yīng)用
supervisorctl restart easyswoole
啟動(dòng)EasySwoole應(yīng)用
supervisorctl start easyswoole
查看所有監(jiān)控的應(yīng)用
supervisorctl status
重新加載配置文件
supervisorctl update
重啟所有應(yīng)用
supervisorctl reload