zoukankan      html  css  js  c++  java
  • Django 使用gunicorn 和 supervisord部署

    安装依赖

    pip3 install gunicorn supervisor
    

    项目部署目录为/code,有2个服务 一个为web服务,一个为任务服务

    生成配置文件

    echo_supervisord_conf > /code/supervisord.conf
    

    /code/supervisord.conf配置

    [program:ccu]
    command=/code/py/bin/gunicorn --chdir /code/project --pythonpath /code/py/ -k gthread --thread 40 --max-requests 4096 --max-requests-jitter 512 -w 4 -b0.0.0.0:8000 project.wsgi
    directory=/code/project
    startsecs=0
    stopwaitsecs=0
    autostart=true
    autorestart=true
    
    [program:ccu_cron]
    command=/code/py/bin/python3 /code/project/run.py
    directory=/code/project
    startsecs=0
    stopwaitsecs=0
    autostart=true
    autorestart=true
    

    gunicorn 参数说明

    name Value
    chdir 加载应用程序之前将chdir目录指定到指定目录
    pythonpath 路径加到python path
    max-requests 工作将处理的最大请求数(静态数值)
    max-requests-jitter 工作将处理的最大请求数(动态数值)randint(0, max_requests_jitter)
    -w 表示开启多少个worker
    project.wsgi project/wsgi.py 文件

    supervisorctl 基本命令

    supervisord -c /etc/supervisord.conf 启动服务
    supervisorctl -c /code/supervisord.conf status              查看状态
    supervisorctl -c /code/supervisord.conf reload              重新载入配置文件
    supervisorctl -c /code/supervisord.conf start [all]|[x]     启动所有/指定的程序进程
    supervisorctl -c /code/supervisord.conf stop [all]|[x]      停止所有/指定的程序进程
    
  • 相关阅读:
    angular安装指定版本
    Fluttter通过按钮来打开抽屉Drawer或者endDrawer
    angular中的animation动画
    flutter pubspec.yaml配置文件详解
    angular-cli卸载安装
    angular的项目基本配置的了解
    angular使用代理解决跨域
    IOS开发之UI布局
    用Objective-C写了一个简单的批量更改文件名的程序
    使用Objective-C 计算代码运行时间
  • 原文地址:https://www.cnblogs.com/sening/p/11350991.html
Copyright © 2011-2022 走看看