This manual to setup Gunicorn in production and use the configuration file.
Gunicorn 0.5 introduced the ability to read configuration from a file. Gunicorn will either look for "gunicorn.conf.py" in the current directory or a file referred through the -c flag.
See github.com/benoitc/gunicorn/blob/master/examples/gunicorn.conf.py.sample for an example of configuration file.
Default configuration settings are:
bind='127.0.0.1:8000',
daemon=False,
debug=False,
logfile='-',
loglevel='info',
pidfile=None,
workers=1,
umask=0,
user=None,
group=None,
after_fork=lambda server, worker: server.log.info(
"worker=%s spawned pid=%s" % (worker.id, str(worker.pid))),
before_fork=lambda server, worker: server.log.info(
"worker=%s spawning" % worker.id),
before_exec=lambda server: server.log.info("forked child, reexecuting")
While some others HTTP proxies can be used we strongly advice you to use NGINX. If you choose another proxy server, make sure it can do buffering to handle slow clients.
An example config file for use with nginx is available at github.com/benoitc/gunicorn/blob/master/examples/nginx.conf.
You may want to monitor Gunicorn service instead of launching it as daemon. You could for example use runit for that purpose. An example config file for use with runit is available at github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc.