Reputation: 2727
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.
Upvotes: 10
Views: 12313
Reputation: 4606
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!
Upvotes: 16
Reputation: 166
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.
Upvotes: 2
Reputation: 3807
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.
Upvotes: 6