• supervisor管理Django进程


    1. 安装:pip install supervisor

    2. 重定向默认配置:echo_supervisord_conf > /etc/supervisord.conf

    3. 修改配置文件目录,修改tmp目录

    4. 启动服务:supervisord -c /etc/supervisord.conf

        查看supervisord是否运行:

        ps -aux|grep supervisord

    5. 项目配置

    6. supervisorctl的使用

        更新新的配置到supervisord:supervisorctl update

        重新启动配置中的所有程序:supervisorctl reload

        启动单个任务进程:supervisorctl start task

        关闭单个任务进程:supervisorctl stop task

        重启单个任务进程:supervisorctl restart task

        重启所有进程:supervisorctl restart all

        关闭所有进程:supervisorctl stop all

        读取有更新(增加)的配置文件,不会启动新添加的程序:supervisorctl reread

        查看进程状态:supervisorctl status

    报错:unix:///var/run/supervisor/supervisor.sock refused connection

    解决:supervisord -c /etc/supervisord.conf 

    配置文件

    mkdir /etc/supervisor

    Django启动配置文件(例如: 项目名称_runserver.conf)

    [program:项目名称_runserver]
    #environment=CLIENT_LOCALE=zh_CN.UTF-8,LD_LIBRARY_PATH=/opt/IBM/Informix_Client-SDK/lib:/opt/IBM/Informix_Client-SDK/lib/esql:/opt/IBM/Informix_Client-SDK/lib/cli
    #environment=INFORMIXDIR=/opt/IBM/Informix_Client-SDK
    environment=DB_LOCALE=zh_CN.UTF-8
    #environment=INFORMIXSQLHOSTS=/home/sqlhosts
    environment=LC_ALL="zh_CN.UTF-8"
    environment=LANG="zh_CN.UTF-8"
    environment=LANGUAGE="zh_CN.UTF-8"
    directory=/usr/local/project/项目名称/
    command=gunicorn 项目名称.wsgi -b 127.0.0.1:18888 --access-logfile /var/log/gunicorn_out.log  --error-logfile /var/log/gunicorn_error.log  -w 4
    path=/usr/local/project/项目名称/
    autostart=true
    autorestart=true
    startretries=10
    exitcode=0
    stopsignal=kill
    stopwaitsecs=10
    user=root
    redirect_stderr=true
    stdout_logfile=/tmp/dtmp_runserver.log
    stopasgroup=true
    killasgroup=true

    nginx.conf

    [program:nginx] 
    command=nginx -c /etc/nginx/nginx.conf -g 'daemon off;' 
    autostart=true 
    autorestart=true
    startretries=10
    exitcode=0
    stopsignal=kill
    stopwaitsecs=10 
    user=root 
    redirect_stderr=true
    stopasgroup=true
    killasgroup=true

    task.conf

    [program:taskinfo] 
    command=/usr/bin/python /usr/local/project/项目名称/manage.py task
    directory=/usr/local/project/项目名称/
    autostart=true 
    autorestart=true
    startretries=10
    exitcode=0
    stopsignal=kill
    stopwaitsecs=10 
    user=root 
    redirect_stderr=true
    stopasgroup=true
    killasgroup=true
    stdout_logfile=/var/log/task_info.log

    参考文档:

    https://www.cnblogs.com/zhaijihai/p/11460502.html

  • 相关阅读:
    Javascript | 模拟mvc实现点餐程序
    DataTables实现按分组小计
    [Webcast]Silverlight探秘系列课程
    python 环境搭建
    MailMessage
    WebRequest
    消息队列(Message Queue)
    c# 缓存
    c# 反射
    数据库连接超时
  • 原文地址:https://www.cnblogs.com/yu121/p/14362290.html
Copyright © 2020-2023  润新知