clime
clime

Reputation: 8885

Django + uwsgi in emperor mode: how to reload wsgi.py of a project

I was deploying a new project on my server but regrettably in wsgi.py of Django project folder, I have had settings for another project (copy-paste and I forget to change it). My wsgi.py looked like this:

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "loserti.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() 

Instead of "loserti.settings" there should have been "cwu.settings". Of course, my project did not work complaing that it cannot find loserti.settings. I have fixed the problem and reloaded the appropriate uwsgi vassal (uwsgi --reload) which I do when I change some python code but that did not help in this case. So I have tried to reload the emperor. That did not help either. In the end I needed to stop and start the emperor which seems definitely to be an overkill. Please, what is the correct way to do that?

Upvotes: 0

Views: 3042

Answers (2)

clime
clime

Reputation: 8885

So the answer is that this

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "loserti.settings")

reset the environment variable DJANGO_SETTINGS_MODULE only if it has not been set yet for the vassal. The thing is that you need to actually kill the vassal (using SIGKILL) so that it is respawned fresh by emperor. After that that change is finally applied.

Upvotes: 1

roberto
roberto

Reputation: 12933

just "touch" the configuration file of your vassal. This will trigger a reload of the whole vassal

Upvotes: 8

Related Questions