安装
pip install superviosr
echo_supervisord_conf > /etc/supervisord.conf
编辑配置文件:
[unix_http_server]
;file=/tmp/supervisor.sock ; (the path to the socket file)
;修改为 /var/run 目录,避免被系统删除 [supervisord]
;logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
;修改为 /var/log 目录,避免被系统删除
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
;pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
;修改为 /var/run 目录,避免被系统删除 [supervisorctl]
; 必须和'unix_http_server'里面的设定匹配
;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
;修改为 /var/run 目录,避免被系统删除 ;解开注释下面两行,表示去/etc/supervisor里找启动程序,/etc/supervisor需要自己创建
[include]
files = /etc/supervisor/*.conf
在/etc/supervisor下创建web.conf:
[program:web]
command=python /root/web/web.py
autorstart=true
autorestart=true
stdout_logfile=/tmp/supervisor.log
启动
supervisord -c /etc/supervisord.conf
supervisorctl可查看status,reload(重新加载配置)
更复杂使用可参考:http://python.jobbole.com/86423/