官方文档:https://docs.vapor.codes/2.0/deploy/supervisor/
相关介绍:https://www.cnblogs.com/zhanghuilong/p/14956121.html
1、安装
1、安装命令
pip install supervisor
或
apt-get install supervisor
2、生成配置文件命令
echo_supervisord_conf >/etc/supervisord.conf
2、开机启动
vim /etc/init.d/supervisord
加入以下内容
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
#
# chkconfig: - 95 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# processname: supervisord
# config: /etc/supervisor/supervisord.conf
# pidfile: /var/run/supervisord.pid
#
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
start() {
echo -n $"Starting supervisord: "
daemon "/usr/bin/supervisord -c /etc/supervisord.conf"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord
}
stop() {
echo -n $"Stopping supervisord: "
killproc supervisord
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/supervisord
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/supervisord ] && restart
;;
status)
status supervisord
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
exit $RETVAL
chmod +x /etc/init.d/supervisord
chkconfig supervisord on
参考链接:https://www.cnblogs.com/laolieren/p/restart_supervisor_when_reboot_system.html
3、使用技巧
tail /etc/supervisord.conf -n 20
;[group:thegroupname]
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
;priority=999 ; the relative start priority (default 999)
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
;[include]
;files = relative/directory/*.ini
[include]
files = /etc/supervisord.d/*.conf
- cat /etc/supervisord.d/cms.conf
[program:cms]
command=/home/work/tomcat/cms-102/apache-tomcat-7.0.88/bin/catalina.sh run
environment=JAVA_HOME="/usr/local/jdk/",JAVA_BIN="/usr/local/jdk/bin"
stdout_logfile=/home/work/tomcat/cms-102/apache-tomcat-7.0.88/logs/catalina.out
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
- cat /etc/supervisord.d/spiderkeeper.conf
[program:spiderkeeper]
command=spiderkeeper --password=xxxxx --server=http://spider_master:6800 --server=http://spider_slave09:6800 --server=http://spider_slave10:6800 --server=http://spider_slave11:6800 --server=http://spider_slave03:6800 --server=http://spider_slave02:6800
directory=/data/project/spiderkeeper/
user=root
stderr_logfile=/var/log/spiderkeeper.err.log
stdout_logfile=/var/log/spiderkeeper.out.log
- cat /etc/supervisord.d/scrapyd.conf
[program:scrapyd]
command=scrapyd
autorestart=true
autorestart=true
redirect_stderr=True
user=root
- cat /etc/supervisord.d/redis.conf
[program:redisd]
command=/data/redis/redis-3.2.8/src/redis-server /data/redis/redis_6379.conf
user=root
startsecs=3
# supervisord -c /etc/supervisord.conf
# supervisorctl
cms RUNNING pid 12328, uptime 5:59:22
scrapd RUNNING pid 10534, uptime 6:31:34
redisd RUNNING pid 10475, uptime 6:31:34
spiderkeeperc RUNNING pid 13469, uptime 4:01:20
# supervisorctl restart cms
# supervisorctl start cms
# supervisorctl stop cms
网友评论