uwsgi管理django进程简介

中文文档: https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/tutorials/Django_and_nginx.html

安装:

      安装python环境和python虚拟环境后,在虚拟环境中通过pip安装:  pip install uwsgi

编写配置文件:

[uwsgi]
socket=127.0.0.1:8000
chdir=.
module=yourapp.wsgi:application
master=True
pidfile=./project-master.pid
vacuum=True
max-requests=5000
daemonize=./uwsgi.log
;虚拟环境中安装uwsgi的,需要指定虚拟环境所在的目录!
home=../your_env_path

processes = %(%k * 2 + 1)
harakiri=20

操作:

    启动: 

        可以设置使用系统方式启动详见文档: https://uwsgi-docs.readthedocs.io/en/latest/Management.html

         手工启动(django): uwsgi --ini uwsgi.ini --protocol=http  // uwsgi安装在虚拟环境中的,启动时一定记得带参数 —protocol=http

        在没有前置服务器(nginx等)的时候启动,需要设置静态文件(参考:https://uwsgi-docs.readthedocs.io/en/latest/StaticFiles.html):

        uwsgi --ini uwsgi.ini --protocol=http --static-map /static=your_static_file_path

    重载: 找到配置中的pidfile指定的文件(/tmp/project-master.pid),作为目标文件进行操作

        # using kill to send the signal

        kill -HUP `cat /tmp/project-master.pid`

        # or the convenience option --reload

        uwsgi --reload /tmp/project-master.pid

    停止: 操作的目标文件同上

        kill -INT `cat /tmp/project-master.pid`

        # or for convenience...

        uwsgi --stop /tmp/project-master.pid

注意: 如果uwsgi已经在运行实例了,再直接执行启动的话,命令行不会报错,但是停止命令和重载命令找不到新的pid,直接杀任务进程也不好使,要处理需要重启系统!所以每次操作前最好看看当前uwsgi是否在运行。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值