3

I am running a django site using uWSGI in emperor mode. I have found that while touching the uwsgi.ini file for a specific application does indeed cause the emperor process to reload that vassal (according to the log file) that a reload is not enough to pick up changes. Specifically changes to the .env file used to configure the django site.

If I move the app specific uwsgi.ini file out of the vassals folder and back in it will work. Presumably because the emperor process kills the vassals once the .ini file is missing and the restarts them when the file reappears. Also restarting the uwsgi emperor using systemd works as well.

I rather not restart the emperor process and the process of moving the ini file around feels awful clunky.

What is the right way to restart single Django site behind emperor and still pick up changes to the site settings?

/etc/uwsgi/emperor.ini

[uwsgi]
emperor = /etc/uwsgi/vassals
uid = www-data
gid = www-data
limit-as = 1024
logto = /tmp/uwsgi.log

/etc/uwsgi/vassals/demo-app.ini

[uwsgi]
chdir=/home/demo-app/demo-app
virtualenv=/home/demo-app/.venv
module=demo_app.wsgi

master = true
processes = 2

socket = 127.0.0.1:1111
chmod-socket = 664
vacuum = true
digitaladdictions
  • 1,465
  • 1
  • 11
  • 29

1 Answers1

1

To restart the single vassal just touch the file

# touch /etc/uwsgi/vassals/demo-app.ini

Uwsgi will detect the change and restart that single service.

danieli
  • 11
  • 2
  • 1
    Note that this appears to not do a full restart - all workers are killed and restarted and the master process re-execs itself, but the emperor does not not restart the master process. This means that some options (I suspect the ones that need root, I've seen this with `listen` and `cgroup`) are not re-applied in this case. On trick to work around this seems to move the .ini file outside of the `vassals` directory, killing the vassal, and then moving it back to restart it from scratch. – Matthijs Kooijman Jun 09 '20 at 09:48