Python进程管理 supervisor常用命令

作者: ZYK的轮子 | 来源:发表于2017-09-26 10:21 被阅读253次
    yum install python-setuptools
    pip install supervisor
    

    测试安装是否成功:

    #echo_supervisord_conf
    

    创建supervisor配置文件目录/etc/supervisor/

    #mkdir -m 755 -p /etc/supervisor/
    

    创建主配文件supervisord.conf

    #echo_supervisord_conf > /etc/supervisor/supervisord.conf
    

    在主配文档中加入执行的程序

    vi /etc/supervisor/supervisord.conf (加入命令行)
    
    [program:index]
    command=python /www/wwwroot/api5.menglechong.net/index.py
    autostart=true   
    autorestart=true   
    redirect_stderr = true 
    stdout_logfile=/root/zyk.log
    [program:replay]
    command=python /www/wwwroot/api5.menglechong.net/replay.py
    autostart=true   
    autorestart=true   
    redirect_stderr = true 
    stdout_logfile=/root/replay.log
    
    [include]
    files = /etc/supervisor/conf.d/*.ini
    

    启动supervisor

    # supervisord -c /etc/supervisor/supervisord.conf
    

    supervisorctl
    supervisorctl -c /etc/supervisor/supervisord.conf
    

    每次修改配置文件后需进入supervisorctl,执行reload

    设置开机自动启动

    1>、进入/lib/systemd/system目录,并创建supervisor.service文件

    [Unit]
    Description=supervisor
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/usr/bin/supervisord -c /etc/supervisor/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
    

    2、 设置开机启动

    systemctl enable supervisor.service
    systemctl daemon-reload
    

    3、修改文件权限为766

    chmod 766 supervisor.service
    

    相关文章

      网友评论

        本文标题:Python进程管理 supervisor常用命令

        本文链接:https://www.haomeiwen.com/subject/spxsextx.html