- wget http://pypi.python.org/packages/source/s/supervisor/supervisor-3.0b1.tar.gz
- tar -zxvf supervisor-3.0b1.tar.gz
- cd supervisor-3.0b1
- python setup.py install
复制代码安装setuptools后也可以
easy_install supervisor
4. 设定supervisor配置文件
创建默认的配置文件
echo_supervisord_conf >/etc/supervisord.conf
vi /etc/supervisord.conf
取消以下的注释,并修改IP为0.0.0.0
[inet_http_server] ; inet (TCP) server disabled by defaultport=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface)username=user ; (default is no username (open server))password=123 ; (default is no password (open server))
增加自定义的后台进程(注意进程名之间用一个:分隔)
[program:hello]command=python /root/hello.pypriority=1numprocs=1autostart=trueautorestart=truestartretries=10stopsignal=KILLstopwaitsecs=10redirect_stderr=truestdout_logfile=/root/hello.log
5. 执行如下命令:
vi /etc/init.d/supervisord
6.输入如下内容:
注意:该文件中的如下几个变量,都需要根据你实际的目录来改写。
PREFIX=/usr/local
SUPERVISORD=$PREFIX/bin/supervisord ##supervisord 程序的安装路径
SUPERVISORCTL=$PREFIX/bin/supervisorctl ##supervisorctl 程序的安装路径
PIDFILE=/var/supervisor/supervisord.pid ##需要先创建/var/supervisor目录
LOCKFILE=/var/supervisor/supervisord.lock
OPTIONS="-c /etc/supervisord.conf" ##配置文件的路径
保存完毕之后,可以执行以下命令修改文件权限:
chmod 777 /etc/init.d/supervisord
/etc/init.d/supervisord start
这样,supervisor就启动了。
7. 配置开机启动
执行以下命令:
chkconfig supervisord on
可以以下命令查看是否成功
chkconfig --list | grep supervisord