Django使用uwsgi和nginx修改代码自动重启

发布时间:2019-10-31 10:33--阅读:1295--评论:2条

在默认设置下,uwsgi本身不会立即加载修改后的文件。nginx + uwsgi + django 部署的站点,如果修改了py代码,需要重新启动 uwsgi 才会生效。如果有需要 Django 代码改动时立即生效,可以在启动 uwsgi 的 ini 的配置文件里加入参数py-autoreload = 1 ( 写在 ini 配置文件中,记得一定要 = 1,否则不生效)。

py-autoreload = 1

完整配置feiublog.ini

    [uwsgi]
    socket = 127.0.0.1:9090
    stats = 127.0.0.1:9191
    chdir = /var/project/feiublog
    wsgi-file =/var/project/feiublog/wsgi.py
    pidfile = /var/project/feiublog/uwsgi_blog.pid
    touch-reload = /var/project/feiublog/uwsgi_blog.pid
    buffer-size = 32768
    processes = 1
    workers= 2
    threads = 2
    daemonize = /tmp/log/uwsgi_blog.log
    py-autoreload = 1  # 代码修改后自动重启

 

正确手动重载uwsgi和代码的方式

使用命令uwsgi feiublog.ini即可自动生成pidfile文件的uswgi_blog.pid

pidfile = /var/project/feiublog/uwsgi_blog.pid

然后在你的uwsgi.pid的目录下执行:

    uwsgi --reload uwsgi_blog.pid
    其中uwsgi_blog.pid即进程的pid文件。

至此,修改后的代码即可自动重载生效

微信公众号ID:feiutech

评论列表

11楼:https://newfasttadalafil.com/ - Cialis SYSTOLIC In the heartbeat cycle the highest measure of blood pressure when the heart contracts to push out blood. <a href=https://newfasttadalafil.com/>buy cheap generic cialis uk</a> Ilkkrd CK level is significantly elevated. levitra pharmacy purchase Hwzvus https://newfasttadalafil.com/ - soft tab cialis Qwjfdw Levitra Ohne Rezept Verkaufen

Frusemi 于2022-05-15 10:37

257楼:<a href=http://bestcialis20mg.com/>п»їcialis</a> While numerous genetic loci impacting the risk for common complex disease have been identified, their clinical use for disease prevention has remained minimal

Beardaple 于2022-11-12 19:17

共2条评论

我要评论

用户名:
邮箱: