• 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
    
  • 相关阅读:
    Android开源项目发现---ImageView 篇(持续更新)
    Android开源项目发现---GridView 篇(持续更新)
    python的setup.py文件
    版本控制系统git
    python如何调用c编译好可执行程序
    Python特殊语法:filter、map、reduce、lambda [转]
    Apache+Mysql+PHP 套件
    django开发环境搭建(参考流程)
    C++ GUI Qt4编程-创建自定义窗口部件
    Qt学习笔记-Widget布局管理
  • 原文地址:https://www.cnblogs.com/yxhblogs/p/8971355.html
Copyright © 2020-2023  润新知