I'm deploying a django/nginx/gunicorn site and am following this guide while doing so. Following the subheading "Final Steps for Production Deployments", I've created a production gunicorn configuration file and am running it from the command line with gunicorn -c config/gunicorn/prod.py
. However, I've noticed that gunicorn will just... stop running, and I'm not sure why. (Worker timeout?)
I'd like to know the following:
- How to set gunicorn up so it keeps running so I don't have to log into prod and kick it,
- When gunicorn dies so I can set up an email alert, because 502s are bad,
- If I'm doing anything wrong.
I did initially attempt to follow this guide, but couldn't get it working with the socket for some reason. I suspect that's the longer-term answer, but again, couldn't get it up and running.
Here is my prod.py
gunicorn conf:
import multiprocessing
wsgi_app = "config.wsgi:application"
loglevel = "info"
workers = multiprocessing.cpu_count() * 2 + 1
bind = "0.0.0.0:8000"
reload = True
accesslog = "/var/log/gunicorn/access.log"
errorlog = "/var/log/gunicorn/error.log"
capture_output = True
pidfile = "/var/run/gunicorn/prod.pid"
daemon = True