yum install -y epel-release yum install -y supervisor
cd /etc/ mkdir supervisord.d echo_supervisord_conf > supervisord.conf vi /etc/supervisord.conf #加入以下配置信息 [include] files = /etc/supervisord.d/*.conf
vi /etc/init.d/supervisord
#!/bin/sh # # /etc/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" prog_bin="/usr/bin/supervisord" PIDFILE="/var/run/$prog.pid" start() { echo -n $"Starting $prog: " ###注意下面这一行一定得有-c /etc/supervisord.conf 不然修改了配置文件根本不生效! daemon $prog_bin -c /etc/supervisord.conf --pidfile $PIDFILE [ -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
chmod +x /etc/init.d/supervisord chkconfig --add supervisord chkconfig supervisord on service supervisord start
vi /etc/supervisord.d/mq_update_code.conf
[program:mq_update_code] user=mit directory=/var/sh/example/code/ command=sh /var/sh/example/code/code1 autostart=true autorestart=true startsecs=5 startretries=3 stderr_logfile=/var/log/update_err.log ;stdout_logfile=/var/log/update_out.log
service supervisord restart supervisorctl update
supervisorctl status //查看所有进程的状态 supervisorctl stop es //停止es进程 配置文件中的process_name supervisorctl start es //启动es supervisorctl restart //重启es supervisorctl update //配置文件修改后使用该命令加载新的配置 supervisorctl reload //重新启动配置中的所有程序
© 2015-2024 杭州极速互联科技有限公司 版权所有 浙ICP备17047587号-4 浙公网安备33010502005096 增值电信业务经营许可证:浙B2-20190875