uwsgi does not reload after changing django settings

爷,独闯天下 提交于 2019-12-08 19:27:04

问题


I have set up uwsgi to serve django behind nginx. Then I change the database in django settings but uwsgi still shows the site with old database.

I also tried this suggestion and added

touch-reload = /etc/uwsgi/apps-available/django.ini

to the ini file. But after restarting uwsgi and touching django.ini it still serves the old site. I tried to deactivate and reactivate virtualenv, no chance either. So really got confused and appreciate your hints.


回答1:


From uWSGI docs about touch-reload: reload uWSGI if the specified file is modified/touched So if you want to reload on changes in settings.py, you should do:

touch-reload = /path/to/your/django-project/settings.py

Directive you've used before reloads uWSGI on any changes in uWSGI ini file.

FYI, of you need to restart uWSGI on changes in codebase also, you can use py-autoreload directive: http://uwsgi-docs.readthedocs.org/en/latest/Options.html#py-autoreload So you should have something like this in your uwsgi.ini

py-autoreload = 1

Note, these options aren't recommended for production. Good luck!




回答2:


This is my uWSGI's configure file

wsgi-file = /home/www-data/djcode/metCCS/metCCS/nginx/wsgi.py
processer = 4
threads = 2
stats = 127.0.0.1:6000
enable-threads = true
master = true
harakiri = 30
socket = /usr/share/nginx/html/ng-sock/metCCS.sock
chmod-socket = 775
uid = www-data
gid = www-data
touch-reload = /home/www-data/djcode/metCCS/metCCS/settings.py

then, touch /home/www-data/djcode/metCCS/metCCS/settings.py works fine.




回答3:


The reason Belter's answer fixed your problem is that uWSGI can only gracefully restart when running with the master process mode. http://uwsgi-docs.readthedocs.io/en/latest/Management.html#reloading-the-server

I just had to add master=true to my ini file to make the touch-reload argument work.



来源:https://stackoverflow.com/questions/27813166/uwsgi-does-not-reload-after-changing-django-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!