supervisor

  1. 安装supervisor

     yum install epel-release -y
     yum install python-pip -y
    
     pip install --upgrade pip
     pip install supervisor
    
  2. 生成配置文件

     echo_supervisord_conf > /etc/supervisord.conf
    
  3. 修改配置

     ; 进程管理,可以单独写到'/etc/supervisord/*.conf'文件内
     [program:进程名1]
     command=[要管理的进程命令]     ; the program (relative uses PATH, can take args)
     process_name=%(program_name)s  ; process_name expr (default %(program_name)s)
     numprocs=1                     ; number of processes copies to start (def 1)
     directory=/tmp                 ; directory to cwd to before exec (def no cwd)
     priority=999                   ; the relative start priority (default 999)
     autostart=true                 ; start at supervisord start (default: true)
     startsecs=1                    ; # of secs prog must stay up to be running (def. 1)
     startretries=5                 ; max # of serial start failures when starting (default 3)
     autorestart=unexpected         ; when to restart if exited after running (def: unexpected)
     user=www                       ; setuid to this UNIX account to run the program
    
     ; 进程组管理
     [group:进程组名]
     programs=进程名1,进程名2       ; each refers to 'x' in [program:x] definitions
     priority=999                   ; the relative start priority (default 999)
    
     [include]
     files = /etc/supervisord/*.conf
    
  4. 完全相同进程启动多个

    参考链接

     [program:进程名2]
     process_name=%(program_name)s_%(process_num)02d ;进程名格式
     command=xxxxxxxxx                               ;进程
     autostart=true                                  ;自动启动
     autorestart=true                                ;自动重启
     user=www                                        ;运行用户
     numprocs=8                                      ;进程数
    
  5. 启动进程管理服务

     supervisord -c /etc/supervisord.conf
    
  6. 进入进程管理控制台

     supervisorctl -c /etc/supervisord.conf
    
  7. 启动所有进程

     # 重新加载配置
     supervisor> reload
     # 重新读取进程
     supervisor> reread
     # 启动所有进程
     supervisor> start all
    
  8. 管理相关命令

     # 重新读取进程
     supervisor> reread
     # 重新加载配置
     supervisor> reload
     # 启动所有进程
     supervisor> start all
     # 停止所有进程
     supervisor> stop all
     # 重启所有进程
     supervisor> restart all
     # 添加进程
     supervisor> add [进程名]
     supervisor> tail   
     supervisor> avail
     supervisor> fg
     supervisor> pid
     supervisor> remove
     supervisor> shutdown
     supervisor> status
     supervisor> update
     supervisor> clear
     # 查看supervisor版本
     supervisor> version
     # 退出supervisor控制台
     supervisor> exit 或 quit
     supervisor> maintail
     supervisor> open
     supervisor> signal
    
@耿志环 2012-∞ 冀ICP备17033181号, powered by Gitbook修订: 2018-05-23 16:25:59

results matching ""

    No results matching ""