[Fixed]-Gunicorn not reloading a Django application


Try this:

$ kill -HUP masterpid

Also, have a look at some of the notes at the bottom of the following post.


I ran into variations of this problem as well — as advised in the article linked to by Mr. Pokomy, killing the gunicorn master process with a HUP signal seems to do the trick.

One can set up auto-reloading on file save easily, if you use the python watchdog module; the setup is actually pretty self-explanatory, so here’s a snippet from my development supervisord.conf file:

command=/usr/local/share/python/gunicorn --debug\
-c /Users/fish/Dropbox/ost2/ost2/utils/gunicorn/ost2-debug.py wsgi_debug
; (etc)

command=/usr/local/share/python/watchmedo shell-command\ 
-R --command='kill -HUP $(cat /usr/local/gunicorn/gunicorn.pid)'\
; (etc)

(N.B. I put the slashes in that sample before newlines that aren’t actually in the conf file — I inserted those newlines for legibility; I am not sure if that works IRL)

The first program is the gunicorn process, which I run in a single thread during development in order to use the Werkzeug debugger. The second part is the interesting bit: that command says, “kill the process specified by the gunicorn PID file whenever there’s a change in a file in this directory tree if the file’s suffix matches one from this list”.

Works like a charm for many including me. If you don’t know it, watchdog is very useful and is worth a look, in its own right.

Leave a comment