2011-10-22 04:30:10 +00:00
|
|
|
===============================
|
|
|
|
How to use Django with Gunicorn
|
|
|
|
===============================
|
|
|
|
|
|
|
|
.. highlight:: bash
|
|
|
|
|
|
|
|
Gunicorn_ ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no
|
2019-06-17 14:54:55 +00:00
|
|
|
dependencies and can be installed using ``pip``.
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2018-09-26 06:48:47 +00:00
|
|
|
.. _Gunicorn: https://gunicorn.org/
|
2011-10-22 04:30:10 +00:00
|
|
|
|
|
|
|
Installing Gunicorn
|
|
|
|
===================
|
|
|
|
|
2019-06-17 14:54:55 +00:00
|
|
|
Install gunicorn by running ``python -m pip install gunicorn``. For more
|
2012-03-03 09:11:54 +00:00
|
|
|
details, see the `gunicorn documentation`_.
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2018-09-26 06:48:47 +00:00
|
|
|
.. _gunicorn documentation: https://docs.gunicorn.org/en/latest/install.html
|
2011-10-22 04:30:10 +00:00
|
|
|
|
|
|
|
Running Django in Gunicorn as a generic WSGI application
|
|
|
|
========================================================
|
|
|
|
|
|
|
|
When Gunicorn is installed, a ``gunicorn`` command is available which starts
|
2019-06-17 14:54:55 +00:00
|
|
|
the Gunicorn server process. The simplest invocation of gunicorn is to pass the
|
|
|
|
location of a module containing a WSGI application object named
|
|
|
|
``application``, which for a typical Django project would look like::
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2014-09-05 23:41:47 +00:00
|
|
|
gunicorn myproject.wsgi
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2014-09-05 23:41:47 +00:00
|
|
|
This will start one process running one thread listening on ``127.0.0.1:8000``.
|
|
|
|
It requires that your project be on the Python path; the simplest way to ensure
|
|
|
|
that is to run this command from the same directory as your ``manage.py`` file.
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2014-08-02 19:02:29 +00:00
|
|
|
See Gunicorn's `deployment documentation`_ for additional tips.
|
2011-10-22 04:30:10 +00:00
|
|
|
|
2018-09-26 06:48:47 +00:00
|
|
|
.. _deployment documentation: https://docs.gunicorn.org/en/latest/deploy.html
|