Supervisor 守护你的进程
Supervisor的安裝與使用入門
?周達(dá)的博客
原文??http://www.51bbo.com/archives/2120
主題?Supervisor
Supervisor是一個(gè)進(jìn)程管理工具,官方的說(shuō)法
用途就是有一個(gè)進(jìn)程需要每時(shí)每刻不斷的跑,但是這個(gè)進(jìn)程又有可能由于各種原因有可能中斷。當(dāng)進(jìn)程中斷的時(shí)候我希望能自動(dòng)重新啟動(dòng)它,此時(shí),我就需要使用到了Supervisor
這個(gè)工具主要就兩個(gè)命令:
supervisord : supervisor的服務(wù)器端部分,啟動(dòng)supervisor就是運(yùn)行這個(gè)命令
supervisorctl:啟動(dòng)supervisor的命令行窗口。
安裝(Centos):
#?yum?install?python-setuptools
#?easy_install?supervisor
如果easy_install不好使就從官方下載:
然后通過(guò)python安裝:
#?tar?zxf?supervisor-3.1.3.tar.gz
#?cd?supervisor
#?python?setup.py?install
成功安裝后可以登陸python控制臺(tái)輸入import supervisor 查看是否能成功加載。
生成配置文件(supervisord.conf):
echo_supervisord_conf > /etc/supervisord.conf
修改配置文件:
在supervisord.conf最后增加(分號(hào)后邊的表示注釋,可以不寫):
[program:bandwidth]
command=python26?/usr/local/bin/bandwidth.sh ?;需要執(zhí)行的命令wd)
user?=root??;(default??is??current??user?,?required??if??root)
autostart=true??;start?at?supervisord?start?(default:?true)
autorestart=true??;whether/when?to?restart?(default:?unexpected)
startsecs=3??;number?of?secs?prog?must?stay?running?(?def?.?1)
stderr_logfile=/tmp/bandwidth_err.log??;redirect?proc?stderr?to?stdout?(default?false)?錯(cuò)誤輸出重定向
stdout_logfile=/tmp/bandwidth.log??;stdout?log?path,?NONE??for??none;?default?AUTO,?log輸出
(更多配置說(shuō)明請(qǐng)參考:http://supervisord.org/configuration.html)
運(yùn)行命令:
supervisord -c /etc/supervisord.conf ?//啟動(dòng)supervisor
supervisorctl //打開(kāi)命令行
[root?@iZ2365j7l5bZ??bin]#?supervisorctl?status ??
bandwidth????????????????????????RUNNING???pid??2423?,?uptime??0?:?06?:?35???
[root?@iZ2365j7l5bZ??bin]#?supervisorctl?help ??
??
default??commands?(type?help?<topic>): ??
===================================== ??
add????clear??fg????????open??quit????remove??restart???start???stop??update? ??
avail??exit???maintail??pid???reload??reread??shutdown??status??tail??version??
ctl中: help //查看命令
ctl中: status //查看狀態(tài)
另外有一個(gè)坑需要注意:如果修改了 /etc/supervisord.conf ,需要執(zhí)行 supervisorctl reload 來(lái)重新加載配置文件,否則不會(huì)生效。。。
轉(zhuǎn)載于:https://blog.51cto.com/312461613/1874427
總結(jié)
以上是生活随笔為你收集整理的Supervisor 守护你的进程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mongodb全套配置
- 下一篇: 初学Node(五)文件I/O