http://www.300168.com/yunwei/show-7897.html

Supervisord是一个使用Python编写的进程管理工具。可以监控和管理进程的状态,管理进程的日志,在程序异常退出时自动重启进程。

Supervisord工具包含两个命令:

supervisord:supervisor的服务程序。
supervisorctl:控制被supervisor管理的进程的命令行工具。
安装Supervisord:

可以通过以下途径安装Supervisord:

包管理器:yum install python-setuptools,apt-get install supervisor。
pip:pip install supervisor。
easy_install:easy_install supervisor。
通过源代码安装。
生成supervisord的配置文件:

echo_supervisord_conf > /etc/supervisord.conf
配置supervisord:

在supervisord.conf最后增加(分号后边的表示注释):

[program:bandwidth]
command=python26 /usr/local/bin/bandwidth.sh
user =root
autostart=true
autorestart=true
startsecs=3
stderr_logfile=/tmp/bandwidth_err.log
stdout_logfile=/tmp/bandwidth.log
详细的配置说明请参考: http://supervisord.org/configuration.html

运行supervisord: