[CentralOH] Debian / Gunicorn

William McVey wam at cisco.com
Thu May 23 15:26:11 CEST 2013


On Wed, 2013-05-22 at 20:32 -0400, John Santiago wrote:
> Has anyone had any experience install gunicorn on debian. Trying to
> figure out the config. What is good set up for wsgi app?

I run most of my wsgi services (a combination of flask and django)
through gunicorn on Ubuntu. I always install gunicorn into the
virtualenv associated with my app/site, so installation is rarely more
than a 'pip install gunicorn' from within the appropriate virtualenv.
(Technically, I use chef to do this for me, but that's a tangent.)
Similar to Brandon, I user supervisord to launch gunicorn, although I
invoke it slightly different:


In /etc/supervisor.d/gunicorn_MY_APP.conf

        command=/srv/MY_APP_NAME/venv/bin/gunicorn_django --config /srv/MY_APP_NAME/app/conf/webserver.py /srv/MY_APP_NAME/app/MY_APP_site/settings.py
        process_name=%(program_name)s
        numprocs=1
        numprocs_start=0
        autostart=true
        autorestart=true
        directory=/srv/bundle_analysis
        serverurl=AUTO
        user=www-data
        startsecs=1
        startretries=3

My gunicorn config file is webserver.py with variables like:

        # What ports/sockets to listen on, and what options for them.
        bind = "0.0.0.0:8000"
        # The maximum number of pending connections
        backlog = 2048
        # What the timeout for killing busy workers is, in seconds
        timeout = 180
        # How long to wait for requests on a Keep-Alive connection, in
        seconds
        keepalive = 2
        # The maxium number of requests a worker will process before
        restarting
        max_requests = 0
        # Whether the app should be pre-loaded
        preload_app = False
        # How many worker processes
        workers = 8
        # Type of worker to use
        worker_class = "sync"

The last argument to the command is the django settings.py file which I
assume you're familiar with.

  -- William



More information about the CentralOH mailing list