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 参数说明

nameValue
chdir加载应用程序之前将chdir目录指定到指定目录
pythonpath路径加到python path
max-requests工作将处理的最大请求数(静态数值)
max-requests-jitter工作将处理的最大请求数(动态数值)randint(0, max_requests_jitter)
-w表示开启多少个worker
project.wsgiproject/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]      停止所有/指定的程序进程

转载于:https://www.cnblogs.com/sening/p/11350991.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值