Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uwsgi does not reload after changing django settings

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.

like image 908
Jand Avatar asked Jan 07 '15 05:01

Jand


People also ask

Is uWSGI multithreaded?

Mandatory options. By default uWSGI does not enable threading support within the Python interpreter core. This means it is not possible to create background threads from Python code.

What is harakiri in uWSGI?

harakiri. A feature of uWSGI that aborts workers that are serving requests for an excessively long time. Configured using the harakiri family of options. Every request that will take longer than the seconds specified in the harakiri timeout will be dropped and the corresponding worker recycled.


2 Answers

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!

like image 165
Andrey Rusanov Avatar answered Oct 23 '22 01:10

Andrey Rusanov


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.

like image 24
Belter Avatar answered Oct 23 '22 01:10

Belter