centos 6.9 安装 supervisor

用 pip 安装

centos 6 需要安装 python 2.7 请参照 :https://www.liaozhiwei.com/post/1349

安装 supervisor

sudo pip2.7 install supervisor

查看 supervisor 的最新版本和文件列表

pip2.7 show -f supervisor
Name: supervisor
Version: 4.2.0
Summary: A system for controlling process state under UNIX
Home-page: http://supervisord.org/
Author: Chris McDonough
Author-email: chrism@plope.com
License: BSD-derived (http://www.repoze.org/LICENSE.txt)
Location: /usr/local/lib/python2.7/site-packages
Requires:
Required-by:
Files:
../../../bin/echo_supervisord_conf
../../../bin/pidproxy
../../../bin/supervisorctl
../../../bin/supervisord
supervisor-4.2.0.dist-info/INSTALLER
supervisor-4.2.0.dist-info/LICENSES.txt
supervisor-4.2.0.dist-info/METADATA
supervisor-4.2.0.dist-info/RECORD
supervisor-4.2.0.dist-info/WHEEL
supervisor-4.2.0.dist-info/entry_points.txt
supervisor-4.2.0.dist-info/top_level.txt
supervisor/__init__.py
supervisor/__init__.pyc
supervisor/__pycache__/__init__.cpython-38.pyc
supervisor/__pycache__/childutils.cpython-38.pyc
supervisor/__pycache__/compat.cpython-38.pyc
supervisor/__pycache__/confecho.cpython-38.pyc
supervisor/__pycache__/datatypes.cpython-38.pyc
supervisor/__pycache__/dispatchers.cpython-38.pyc
supervisor/__pycache__/events.cpython-38.pyc
supervisor/__pycache__/http.cpython-38.pyc
supervisor/__pycache__/http_client.cpython-38.pyc
supervisor/__pycache__/loggers.cpython-38.pyc
supervisor/__pycache__/options.cpython-38.pyc
supervisor/__pycache__/pidproxy.cpython-38.pyc
supervisor/__pycache__/poller.cpython-38.pyc
supervisor/__pycache__/process.cpython-38.pyc
supervisor/__pycache__/rpcinterface.cpython-38.pyc
supervisor/__pycache__/socket_manager.cpython-38.pyc
supervisor/__pycache__/states.cpython-38.pyc
supervisor/__pycache__/supervisorctl.cpython-38.pyc
supervisor/__pycache__/supervisord.cpython-38.pyc
supervisor/__pycache__/templating.cpython-38.pyc
supervisor/__pycache__/web.cpython-38.pyc
supervisor/__pycache__/xmlrpc.cpython-38.pyc
supervisor/childutils.py
supervisor/childutils.pyc
supervisor/compat.py
supervisor/compat.pyc
supervisor/confecho.py
supervisor/confecho.pyc
supervisor/datatypes.py
supervisor/datatypes.pyc
supervisor/dispatchers.py
supervisor/dispatchers.pyc
supervisor/events.py
supervisor/events.pyc
supervisor/http.py
supervisor/http.pyc
supervisor/http_client.py
supervisor/http_client.pyc
supervisor/loggers.py
supervisor/loggers.pyc
supervisor/medusa/__init__.py
supervisor/medusa/__init__.pyc
supervisor/medusa/__pycache__/__init__.cpython-38.pyc
supervisor/medusa/__pycache__/asynchat_25.cpython-38.pyc
supervisor/medusa/__pycache__/asyncore_25.cpython-38.pyc
supervisor/medusa/__pycache__/auth_handler.cpython-38.pyc
supervisor/medusa/__pycache__/counter.cpython-38.pyc
supervisor/medusa/__pycache__/default_handler.cpython-38.pyc
supervisor/medusa/__pycache__/filesys.cpython-38.pyc
supervisor/medusa/__pycache__/http_date.cpython-38.pyc
supervisor/medusa/__pycache__/http_server.cpython-38.pyc
supervisor/medusa/__pycache__/logger.cpython-38.pyc
supervisor/medusa/__pycache__/m_syslog.cpython-38.pyc
supervisor/medusa/__pycache__/medusa_gif.cpython-38.pyc
supervisor/medusa/__pycache__/producers.cpython-38.pyc
supervisor/medusa/__pycache__/status_handler.cpython-38.pyc
supervisor/medusa/__pycache__/util.cpython-38.pyc
supervisor/medusa/__pycache__/xmlrpc_handler.cpython-38.pyc
supervisor/medusa/asynchat_25.py
supervisor/medusa/asynchat_25.pyc
supervisor/medusa/asyncore_25.py
supervisor/medusa/asyncore_25.pyc
supervisor/medusa/auth_handler.py
supervisor/medusa/auth_handler.pyc
supervisor/medusa/counter.py
supervisor/medusa/counter.pyc
supervisor/medusa/default_handler.py
supervisor/medusa/default_handler.pyc
supervisor/medusa/filesys.py
supervisor/medusa/filesys.pyc
supervisor/medusa/http_date.py
supervisor/medusa/http_date.pyc
supervisor/medusa/http_server.py
supervisor/medusa/http_server.pyc
supervisor/medusa/logger.py
supervisor/medusa/logger.pyc
supervisor/medusa/m_syslog.py
supervisor/medusa/m_syslog.pyc
supervisor/medusa/medusa_gif.py
supervisor/medusa/medusa_gif.pyc
supervisor/medusa/producers.py
supervisor/medusa/producers.pyc
supervisor/medusa/status_handler.py
supervisor/medusa/status_handler.pyc
supervisor/medusa/util.py
supervisor/medusa/util.pyc
supervisor/medusa/xmlrpc_handler.py
supervisor/medusa/xmlrpc_handler.pyc
supervisor/options.py
supervisor/options.pyc
supervisor/pidproxy.py
supervisor/pidproxy.pyc
supervisor/poller.py
supervisor/poller.pyc
supervisor/process.py
supervisor/process.pyc
supervisor/rpcinterface.py
supervisor/rpcinterface.pyc
supervisor/scripts/__pycache__/loop_eventgen.cpython-38.pyc
supervisor/scripts/__pycache__/loop_listener.cpython-38.pyc
supervisor/scripts/__pycache__/sample_commevent.cpython-38.pyc
supervisor/scripts/__pycache__/sample_eventlistener.cpython-38.pyc
supervisor/scripts/__pycache__/sample_exiting_eventlistener.cpython-38.pyc
supervisor/scripts/loop_eventgen.py
supervisor/scripts/loop_eventgen.pyc
supervisor/scripts/loop_listener.py
supervisor/scripts/loop_listener.pyc
supervisor/scripts/sample_commevent.py
supervisor/scripts/sample_commevent.pyc
supervisor/scripts/sample_eventlistener.py
supervisor/scripts/sample_eventlistener.pyc
supervisor/scripts/sample_exiting_eventlistener.py
supervisor/scripts/sample_exiting_eventlistener.pyc
supervisor/skel/sample.conf
supervisor/socket_manager.py
supervisor/socket_manager.pyc
supervisor/states.py
supervisor/states.pyc
supervisor/supervisorctl.py
supervisor/supervisorctl.pyc
supervisor/supervisord.py
supervisor/supervisord.pyc
supervisor/templating.py
supervisor/templating.pyc
supervisor/tests/__init__.py
supervisor/tests/__init__.pyc
supervisor/tests/__pycache__/__init__.cpython-38.pyc
supervisor/tests/__pycache__/base.cpython-38.pyc
supervisor/tests/__pycache__/test_childutils.cpython-38.pyc
supervisor/tests/__pycache__/test_confecho.cpython-38.pyc
supervisor/tests/__pycache__/test_datatypes.cpython-38.pyc
supervisor/tests/__pycache__/test_dispatchers.cpython-38.pyc
supervisor/tests/__pycache__/test_end_to_end.cpython-38.pyc
supervisor/tests/__pycache__/test_events.cpython-38.pyc
supervisor/tests/__pycache__/test_http.cpython-38.pyc
supervisor/tests/__pycache__/test_http_client.cpython-38.pyc
supervisor/tests/__pycache__/test_loggers.cpython-38.pyc
supervisor/tests/__pycache__/test_options.cpython-38.pyc
supervisor/tests/__pycache__/test_poller.cpython-38.pyc
supervisor/tests/__pycache__/test_process.cpython-38.pyc
supervisor/tests/__pycache__/test_rpcinterfaces.cpython-38.pyc
supervisor/tests/__pycache__/test_socket_manager.cpython-38.pyc
supervisor/tests/__pycache__/test_states.cpython-38.pyc
supervisor/tests/__pycache__/test_supervisorctl.cpython-38.pyc
supervisor/tests/__pycache__/test_supervisord.cpython-38.pyc
supervisor/tests/__pycache__/test_templating.cpython-38.pyc
supervisor/tests/__pycache__/test_web.cpython-38.pyc
supervisor/tests/__pycache__/test_xmlrpc.cpython-38.pyc
supervisor/tests/base.py
supervisor/tests/base.pyc
supervisor/tests/fixtures/__pycache__/listener.cpython-38.pyc
supervisor/tests/fixtures/__pycache__/spew.cpython-38.pyc
supervisor/tests/fixtures/__pycache__/test_1231.cpython-38.pyc
supervisor/tests/fixtures/__pycache__/unkillable_spew.cpython-38.pyc
supervisor/tests/fixtures/donothing.conf
supervisor/tests/fixtures/example/included.conf
supervisor/tests/fixtures/example/issue-1184.conf
supervisor/tests/fixtures/include.conf
supervisor/tests/fixtures/issue-1054.conf
supervisor/tests/fixtures/issue-1224.conf
supervisor/tests/fixtures/issue-1231.conf
supervisor/tests/fixtures/issue-1231a.conf
supervisor/tests/fixtures/issue-1231b.conf
supervisor/tests/fixtures/issue-1231c.conf
supervisor/tests/fixtures/issue-1298.conf
supervisor/tests/fixtures/issue-565.conf
supervisor/tests/fixtures/issue-638.conf
supervisor/tests/fixtures/issue-663.conf
supervisor/tests/fixtures/issue-664.conf
supervisor/tests/fixtures/issue-835.conf
supervisor/tests/fixtures/issue-836.conf
supervisor/tests/fixtures/listener.py
supervisor/tests/fixtures/listener.pyc
supervisor/tests/fixtures/spew.py
supervisor/tests/fixtures/spew.pyc
supervisor/tests/fixtures/test_1231.py
supervisor/tests/fixtures/test_1231.pyc
supervisor/tests/fixtures/unkillable_spew.py
supervisor/tests/fixtures/unkillable_spew.pyc
supervisor/tests/test_childutils.py
supervisor/tests/test_childutils.pyc
supervisor/tests/test_confecho.py
supervisor/tests/test_confecho.pyc
supervisor/tests/test_datatypes.py
supervisor/tests/test_datatypes.pyc
supervisor/tests/test_dispatchers.py
supervisor/tests/test_dispatchers.pyc
supervisor/tests/test_end_to_end.py
supervisor/tests/test_end_to_end.pyc
supervisor/tests/test_events.py
supervisor/tests/test_events.pyc
supervisor/tests/test_http.py
supervisor/tests/test_http.pyc
supervisor/tests/test_http_client.py
supervisor/tests/test_http_client.pyc
supervisor/tests/test_loggers.py
supervisor/tests/test_loggers.pyc
supervisor/tests/test_options.py
supervisor/tests/test_options.pyc
supervisor/tests/test_poller.py
supervisor/tests/test_poller.pyc
supervisor/tests/test_process.py
supervisor/tests/test_process.pyc
supervisor/tests/test_rpcinterfaces.py
supervisor/tests/test_rpcinterfaces.pyc
supervisor/tests/test_socket_manager.py
supervisor/tests/test_socket_manager.pyc
supervisor/tests/test_states.py
supervisor/tests/test_states.pyc
supervisor/tests/test_supervisorctl.py
supervisor/tests/test_supervisorctl.pyc
supervisor/tests/test_supervisord.py
supervisor/tests/test_supervisord.pyc
supervisor/tests/test_templating.py
supervisor/tests/test_templating.pyc
supervisor/tests/test_web.py
supervisor/tests/test_web.pyc
supervisor/tests/test_xmlrpc.py
supervisor/tests/test_xmlrpc.pyc
supervisor/ui/images/button_refresh.gif
supervisor/ui/images/button_restart.gif
supervisor/ui/images/button_stop.gif
supervisor/ui/images/icon.png
supervisor/ui/images/rule.gif
supervisor/ui/images/state0.gif
supervisor/ui/images/state1.gif
supervisor/ui/images/state2.gif
supervisor/ui/images/state3.gif
supervisor/ui/images/supervisor.gif
supervisor/ui/status.html
supervisor/ui/stylesheets/supervisor.css
supervisor/ui/tail.html
supervisor/version.txt
supervisor/web.py
supervisor/web.pyc
supervisor/xmlrpc.py
supervisor/xmlrpc.pyc

可以看到 Location/usr/local/lib/python2.7/site-packages,和Files的前几个文件

  ../../../bin/echo_supervisord_conf
  ../../../bin/pidproxy
  ../../../bin/supervisorctl
  ../../../bin/supervisord

其中../../../相对路径/usr/local/lib/python2.7/site-packages得到绝对路径是:/usr/local
那前四个文件的绝对路径是:

/usr/local/bin/echo_supervisord_conf
/usr/local/bin/pidproxy
/usr/local/bin/supervisorctl
/usr/local/bin/supervisord
生成 supervisor 的配置文件
echo_supervisord_conf | sudo tee /etc/supervisord.conf

如果是root用户可以用

echo_supervisord_conf > /etc/supervisord.conf

如果提示 -bash: echo_supervisord_conf: command not found说明/usr/local/bin没有添加到visudosecure_path内,解决方法是:

编辑visudo

sudo visudo

找到 secure_path这一行

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

添加/usr/local/sbin/usr/local/bin,变成这样

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

保存编辑即可

创建一个配置文件夹,多个服务的配置文件单独放置

sudo mkdir -p /etc/supervisor.d

修改配置文件

sudo vim /etc/supervisord.conf

找到 ;[include]去掉;变成[include]

找到[include]下面的;files去掉;变成files

files = relative/directory/*.ini改成files = /etc/supervisor.d/*.conf

其它配置默认即可,保存修改

添加 /etc/init.d/supervisor 开机启动
sudo vim /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/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/local"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"
conf="/etc/supervisord.conf"

start()
{
        echo -n $"Starting $prog: "
        daemon $prog_bin --pidfile $PIDFILE -c $conf
        [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
        echo
}

stop()
{
        echo -n $"Shutting down $prog: "
        [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
        echo
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
        status $prog
  ;;

  restart)
    stop
    start
  ;;

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

esac

增加可执行权限

sudo chmod +x /etc/init.d/supervisord

centos 添加开机启动

sudo chkconfig --add supervisord
sudo chkconfig --level 2345 supervisord on

启动 supervisord

sudo /etc/init.d/supervisord start

参考:
http://www.alphadevx.com/a/455-Installing-Supervisor-and-Superlance-on-CentOS