Supervisor安装及配置

Supervisor安装

# 安装
easy_install supervisor
# 生成默认配置文件
echo_supervisord_conf > /etc/supervisord.conf
mkdir /etc/supervisord.conf.d

修改配置文件

include区段修改为

[include]
files = /etc/supervisord.conf.d/*.conf

如需要访问web控制界面,inet_http_server区段修改为

[inet_http_server]
port=0.0.0.0:9001
username=username ; 你的用户名
password=password ; 你的密码

每个需要管理的进程分别写在一个文件里面,放在/etc/supervisord.conf.d/目录下,便于管理。例如:test.conf

[program:sqlparse]
directory = /var/www/python
command = /bin/env python test.py

将supervisord加入系统服务,以下代码来自gist,文件:/etc/init.d/supervisord

#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/init.d/functions

RETVAL=0
prog="supervisord"
pidfile="/tmp/supervisord.pid"
lockfile="/var/lock/subsys/supervisord"

start()
{
        echo -n $"Starting $prog: "
        daemon --pidfile $pidfile supervisord -c /etc/supervisord.conf
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch ${lockfile}
}

stop()
{
        echo -n $"Shutting down $prog: "
        killproc -p ${pidfile} /usr/bin/supervisord
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ] ; then
                rm -f ${lockfile} ${pidfile}
        fi
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
        status $prog
  ;;

  restart)
    stop
    start
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
  ;;

esac
chmod +x /etc/init.d/supervisord
chkconfig supervisord on
service supervisord start

标签: none

已有 6 条评论

  1. 乖蜀黍很囧 乖蜀黍很囧

    http://0.0.0.0:9001 refused connection
    怎么回事?

  2. 思哥 思哥

    请问有supervisor和node.js结合的使用教程吗,linux的

    1. 思哥 思哥

      我看到了,我去试试。

  3. include 区域不生效。

    1. zhuansanquan zhuansanquan

      我也没生效,你解决了吗

    2. 那不可能,除非你写错什么东西了

添加新评论