zoukankan      html  css  js  c++  java
  • Centos7 使用 supervisor 管理进程

    一、安装

    //直接使用pip安装(pip的安装 http://www.cnblogs.com/yxhblogs/p/8971251.html)
    pip install supervisor
    

    二、配置

    //运行echo_supervisord_conf 命令重定向到一个配置文件
    echo_supervisord_conf > /etc/supervisord.conf
    

    三、修改配置文件

    //创建一个目录
    mkdir /etc/supervisor.d
    
    //把/etc/supervisord.conf 里 include 部分的的配置修改一下,改为如下:
    [include]
    files = /etc/supervisor.d/*.conf
    

    四、program 配置

    [root@localhost supervisord.d]# cat test.conf 
    ;[program:theprogramname]
    ;command=/bin/cat              ; 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=/var/tmp                ; directory to cwd to before exec (def no cwd) //程序的启动目录
    ;umask=022                     ; umask for process (default None)
    ;priority=999                  ; the relative start priority (default 999)
    ;autostart=true                ; start at supervisord start (default: true) //在 supervisord 启动的时候也自动启动
    ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)   //启动 1 秒后没有异常退出,就当作已经正常启动了
    ;startretries=3                ; max # of serial start failures when starting (default 3) //启动失败自动重试次数,默认是 3
    ;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
    ;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
    ;stopsignal=QUIT               ; signal used to kill process (default TERM)
    ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
    ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
    ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
    ;user=chrism                   ; setuid to this UNIX account to run the program //用哪个用户启动
    ;redirect_stderr=true          ; redirect proc stderr to stdout (default false) //把 stderr 重定向到 stdout,默认 false
    ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
    ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB) //stdout 日志文件大小,默认 50MB
    ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10) //stdout 日志文件备份数 , 默认10
    ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
    ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
    ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    ;environment=A="1",B="2"       ; process environment additions (def no adds)
    ;serverurl=AUTO                ; override serverurl computation (childutils)
    
    更详细配置请参考:https://blog.csdn.net/chenyulancn/article/details/52789565
    

    五、启动

    //启动supervisor
    supervisord -c /etc/supervisord.conf
    
  • 相关阅读:
    hash表及带注释插头dp
    NOIP模拟测试9「随·单·题」
    静态点分治总结
    NOIP模拟测试8「匹配·回家」
    NOIP模拟测试8「寿司」
    「PKUWC2018」Slay the Spire
    矩阵快速幂总结
    SQL中的object_id函数
    SQL数据库Replace的用法
    SQL批量提交修改业务
  • 原文地址:https://www.cnblogs.com/yxhblogs/p/8971355.html
Copyright © 2011-2022 走看看