#第一种(推荐)
yum install python-setuptools
easy_install supervisor
#第二种
yum install python-setuptools
easy_install pip
pip install supervisor
#第三种
yum install -y epel-release
yum install -y supervisor
tar zxvf setuptools-36.6.0.tar.gz
cd setuptools-36.6.0
python bootstrap.py install
python setup.py install
tar zxvf meld3.tar.gz
cd meld3
python setup.py install
tar zxvf elementtree-1.2.6-20050316.tar.gz
cd elementtree-1.2.6-20050316
python setup.py install
tar zxvf supervisor-3.3.3.tar.gz
cd supervisor-3.3.3
python setup.py install
echo_supervisord_conf > /etc/supervisord.confmkdir -p /var/log/supervisormkdir -p /etc/supervisor/conf.d/echo -e "[include]\nfiles = /etc/supervisor/conf.d/*.conf">>/etc/supervisord.conf/usr/bin/supervisord/etc/supervisord.confps -ef | grep supervisord,kill 对应的 pidvim /etc/supervisor/conf.d/logstash.conf[program:gitnavi-logstash]
command=/usr/program/elk/logstash-2.4.1/bin/logstash -f /usr/program/elk/logstash-2.4.1/config/logstash.conf
stdout_logfile=/var/log/supervisor/supervisord-logstash.log
stderr_logfile=/var/log/supervisor/supervisord-logstash-err.log
user=root
autostart=true
autorestart=false
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
/usr/bin/supervisord -c /etc/supervisord.conf/usr/bin/supervisorctl status/usr/bin/supervisorctl start all/usr/bin/supervisorctl stop all/usr/bin/supervisorctl start gitnavi-logstash/usr/bin/supervisorctl stop gitnavi-logstash/usr/bin/supervisorctl restart gitnavi-logstash/usr/bin/supervisorctl reread/usr/bin/supervisorctl reload/usr/bin/supervisorctl update/usr/bin/supervisorctl statussupervisorctl,会进入 supervisord 的交互模式下,如果当前有启动的任务,还可以看到对应的任务情况。
stop gitnavi-logstashstop allstart allhelpvim /etc/init.d/supervisord#!/bin/sh
#
# 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 755 /etc/init.d/supervisordchkconfig supervisord onservice supervisord startservice supervisord stopvim /lib/systemd/system/supervisor.service[Unit]
Description=supervisor
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
chmod 766 /lib/systemd/system/supervisor.servicesystemctl enable supervisor.servicesystemctl daemon-reload