supervisor开机自启动方法

配置service类型服务

 1 #!/bin/bash
 2 #
 3 # supervisord   This scripts turns supervisord on
 4 #
 5 # Author:       Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
 6 #
 7 # chkconfig:    - 95 04
 8 #
 9 # description:  supervisor is a process control utility.  It has a web based
10 #               xmlrpc interface as well as a few other nifty features.
11 # processname:  supervisord
12 # config: /etc/supervisor/supervisord.conf
13 # pidfile: /var/run/supervisord.pid
14 #
15 
16 # source function library
17 . /etc/rc.d/init.d/functions
18 
19 RETVAL=0
20 
21 start() {
22     echo -n $"Starting supervisord: "
23     daemon "/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf "
24     RETVAL=$?
25     echo
26     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord
27 }
28 
29 stop() {
30     echo -n $"Stopping supervisord: "
31     killproc supervisord
32     echo
33     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/supervisord
34 }
35 
36 restart() {
37     stop
38     start
39 }
40 
41 case "$1" in
42   start)
43     start
44     ;;
45   stop) 
46     stop
47     ;;
48   restart|force-reload|reload)
49     restart
50     ;;
51   condrestart)
52     [ -f /var/lock/subsys/supervisord ] && restart
53     ;;
54   status)
55     status supervisord
56     RETVAL=$?
57     ;;
58   *)
59     echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
60     exit 1
61 esac
62 
63 exit $RETVAL

将上述脚本内容保存到/etc/rc.d/init.d/supervisor文件中,修改文件权限为755,并设置开机启动

chmod 755 /etc/rc.d/init.d/supervisor
chkconfig supervisor on

注意:修改脚本中supervisor配置文件路径为你的supervisor的配置文件路径

Supervisor只能管理非daemon的进程,也就是说Supervisor不能管理守护进程。否则提示Exited too quickly (process log may have details)异常。例子中的Tomcat默认是以守护进程启动的,所以我们改成了catalina.sh run,以前台进程的方式运行

来源:http://blog.csdn.net/xyang81/article/details/51555473

原文地址:https://www.cnblogs.com/shengulong/p/7641069.html