Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can't remember where, but I read uWSGI can reload itself like Django development server when a project script is modified. I can't find that in the docs, nor in the internets. How can I do this?

I use Ubuntu 12.04 on my working machines and Debian Squeeze on stage & production server, Django 1.4 and uWSGI 1.2.

share|improve this question
up vote 21 down vote accepted

Reference: http://projects.unbit.it/uwsgi/wiki/Management

If you have started uwsgi with the --touch-reload=/path/to/special/file/usually/the.ini option, reloading your uWSGI is a simple matter of touch reloading that file with

touch /path/to/special/file/usually/the.ini

And if you want the "autoreload" capability, this is the tip that gets this done: http://projects.unbit.it/uwsgi/wiki/TipsAndTricks#uWSGIdjangoautoreloadmode

share|improve this answer

There is a py-autoreload=N option in newer releases. Just set N to the frequency (in seconds) of checks (3 is a good value).

share|improve this answer
1  
This is even better, thanks! – culebrón Jul 27 '12 at 10:40
7  
"use only in development" according to uwsgi docs – scytale Jan 28 '13 at 17:32
2  
looks like touch-reload=/some/file is a safer option – scytale Jan 28 '13 at 17:34

If you don't want lose the django autoreload, register this reload method (i.e: in settings.py):

import uwsgi
from uwsgidecorators import timer
from django.utils import autoreload

@timer(3)
def change_code_gracefull_reload(sig):
    if autoreload.code_changed():
        uwsgi.reload()

Now if you change your code it will be reloaded.

Author: Simone Federici

share|improve this answer
    
This worked perfectly. Also added a conditional so this only gets called in the development environment. – 2upmedia Sep 23 '15 at 18:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.