How do I make uWSGI restart when a Python script is modified?

Solution 1:

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

Solution 2:

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).


Solution 3:

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

Tags:

Django

Uwsgi