supervisor進(jìn)程管理
supervisor就是用Python開發(fā)的一套通用的進(jìn)程管理程序,能將一個(gè)普通的命令行進(jìn)程變?yōu)楹笈_(tái)daemon由捎,并監(jiān)控進(jìn)程狀態(tài)兔综,異常退出時(shí)能自動(dòng)重啟。
安裝
apt-get install supervisor
在supervisor的配置文件中:
vim /etc/supervisor/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf
在配置文件末尾指定了要以supervisor監(jiān)控的程序運(yùn)行的配置文件所在路徑狞玛。
在/etc/supervisor/conf.d/在創(chuàng)建新的文件test.conf
[program:django]
command=/usr/bin/python manage.py runserver 0.0.0.0:8080
directory=/root/django/HTTP_Headers
autostart=true
autorestart=true
autorestart=unexpected
user=root
重啟supervisor服務(wù)
root@iZ28m24is39Z:/etc/supervisor/conf.d# service supervisor restart
Restarting supervisor: supervisord.
root@iZ28m24is39Z:/etc/supervisor/conf.d# supervisorctl
django RUNNING pid 2645, uptime 3 days, 18:39:27
supervisor>
那么test.conf中指定的程序已經(jīng)已后臺(tái)運(yùn)行的方式啟動(dòng)软驰。