supervisor 工具 配置

配置supervisor工具,管理django后台

  • supervisor管理进程,是通过fork/exec的方式将这些被管理的进程当作supervisor的子进程来启动,所以我们只需要将要管理进程的可执行文件的路径添加到supervisor的配置文件中就好了。此时被管理进程被视为supervisor的子进程,若该子进程异常中断,则父进程可以准确的获取子进程异常中断的信息,通过在配置文件中设置autostart=ture,可以实现对异常中断的子进程的自动重启。

  • 这个东西只能用python2去实现

  1. 下载supervisor
    easy_install supervisor

  2. 配置supervisor的配置文件,编写django任务
    echo_supervisord_conf > /etc/supervisor.conf

  3. 编写运行django的任务
    vim /etc/supervisor.conf
    在最底行写入如下代码

    [program:s16alicrm]
    command=/root/Envs/alicrm/bin/uwsgi  --ini /opt/Alibab_crm/uwsgi.ini 
    autorestart=true
    stopasgroup=true
    killasgroup=true
  4. 启动suopersivod这个程序
    启动服务端
    supervisord -c /etc/supervisor.conf
    通过客户端命令查看任务
    supervisorctl -c /etc/supervisor.conf

学习supervisor管理命令

[root@s16ds alicrm]# supervisorctl -c /etc/supervisor.conf
s16alicrm RUNNING pid 5293, uptime 0:03:03

supervisor> stop all #停止所有任务
supervisor> start all #启动s所有任务
supervisor> status s16alicrm

猜你喜欢

转载自www.cnblogs.com/zhang-zi-yi/p/10792359.html