1.安装
easy_install supervisor
2.配置文件生成
echo_supervisord_conf > /etc/supervisord.conf
3.管理脚本
centos 7
添加文件到
/usr/lib/systemd/system/supervisord.service
文件内容
# supervisord service for systemd (CentOS 7.0+) # by ET-CS (https://github.com/ET-CS) [Unit] Description=Supervisor daemon [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
systemctl enable supervisord.service systemctl start supervisord
centos 6.5
添加文件到
/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
4.常用命令
管理Supervisor
启动
service supervisord start
关闭
service supervisord stop
重启
service supervisord restart
查看当前监控进程:supervisorctl status