配置如下(/etc/supervisord.conf):
[unix_http_server] ; supervisord的unix socket服务配置
file=/tmp/supervisor.sock ; socket文件的保存目录
#[inet_http_server] ; supervisord的tcp服务配置
#port=0.0.0.0:9090 ; tcp端口
#username= ; tcp登陆用户
#password= ; tcp登陆密码
[supervisord] ; supervisord的主进程配置
logfile=/data/log/supervisord.log ; 主要的进程日志配置
logfile_maxbytes=50MB ; 最大日志体积,默认50MB
logfile_backups=10 ; 日志文件备份数目,默认10
loglevel=info ; 日志级别,默认info; 还有:debug,warn,trace
pidfile=/var/run/supervisord.pid ; supervisord的pidfile文件
nodaemon=false ; 是否以守护进程的方式启动
minfds=1024 ; 最小的有效文件描述符,默认1024
minprocs=200 ; 最小的有效进程描述符,默认200
user=root ; 默认为当前用户,如果为root则必填
childlogdir=/data/log ; ('AUTO' child log dir, default $TEMP)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[program:BT_local]
command=/usr/bin/beanstalkd -l 0.0.0.0 -p 11300 -b /data/beanstalk/local -f 1000 -z 10485759
[program:uwsgi]
command=/data/web/venv/bin/uwsgi --ini /data/web/app_uwsgi.ini
[program:explain_excels]
command=/usr/bin/python /data/web/explain_excels.py
设置开机启动(/etc/init.d/supervisord):
#! /usr/bin/env bash
# chkconfig: - 85 15
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PROGNAME=supervisord
DAEMON=/usr/bin/$PROGNAME
CONFIG=/etc/$PROGNAME.conf
PIDFILE=/var/run/$PROGNAME.pid
DESC="supervisord daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
start()
{
echo -n "Starting $DESC: $PROGNAME"
$DAEMON -c $CONFIG
echo ".............start success"
}
stop()
{
echo "Stopping $DESC: $PROGNAME"
if [ -f "$PIDFILE" ];
then
supervisor_pid=$(cat $PIDFILE)
kill -15 $supervisor_pid
echo "......"
echo "stop success"
else
echo "$DESC: $PROGNAME is not Runing"
echo ".........................stop sucess"
fi
}
status()
{
if [ -f "$PIDFILE" ];
then
supervisor_pid=$(cat $PIDFILE)
echo "$DESC: $PROGNAME is Runing pid=$supervisor_pid"
else
echo "$DESC: $PROGNAME is not Runing"
echo "please use command /etc/init.d/supervisord start Run the service"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
运行命令:
完成开机启动配置。chkconfig --add suervisord