Last Updated: February 25, 2016
·
3.766K
· galuszkak

Supervisord + Gunicorn

If you are using supervisord for supervising process there is some catches.

For example :

[program:gunicorn]
command=/usr/local/bin/gunicorn_django -b 127.0.0.1:9001 -u www-data project/settings.py -D --error-logfile ../logs/error_gunicorn -w 4
directory=/var/www/project/sources/
user=www-data
autostart=true
autorestart=true
redirect_stderr=True

And this will give you an error:

supervisor> restart gunicorn
gunicorn: ERROR (not running)
gunicorn: ERROR (abnormal termination)

Why this is happening? Beacuse process start us daemon. Simple fix for that is removing flag -D:

command=/usr/local/bin/gunicorn_django -b 127.0.0.1:9001 -u www-data project/settings.py --error-logfile ../logs/error_gunicorn -w 4

And everything is working fine:

supervisor> status
gunicorn                         RUNNING    pid 26463, uptime 0:01:56