Touch up and integrate docs on deploying Flask.

This commit is contained in:
Ron DuPlain 2011-06-10 12:15:50 -04:00
parent 5127b8bd26
commit 207006f4c3
6 changed files with 145 additions and 123 deletions

View file

@ -1,21 +1,25 @@
.. _deploying-uwsgi:
uWSGI
=====
A newly popular deployment method on servers like `cherokee`_ and `nginx`_
is uWSGI. To use your WSGI application with uWSGI protocol you will need
a uWSGI server first. uWSGI is both a protocol and an application server;
the application server can serve uWSGI, FastCGI, and HTTP protocols.
uWSGI is a deployment option on servers like `nginx`_, `lighttpd`_, and
`cherokee`_; see :ref:`deploying-fastcgi` and
:ref:`deploying-other-servers` for other options. To use your WSGI
application with uWSGI protocol you will need a uWSGI server
first. uWSGI is both a protocol and an application server; the
application server can serve uWSGI, FastCGI, and HTTP protocols.
The most popular server is `uwsgi`_, which we will use for this guide.
Make sure to have it installed.
The most popular uWSGI server is `uwsgi`_, which we will use for this
guide. Make sure to have it installed to follow along.
.. admonition:: Watch Out
Please make sure in advance that your ``app.run()`` call you might
have in your application file, is inside an ``if __name__ ==
'__main__':`` or moved to a separate file. Just make sure it's not
called because this will always start a local WSGI server which we do
not want if we deploy that application to uWSGI.
Please make sure in advance that any ``app.run()`` calls you might
have in your application file are inside an ``if __name__ ==
'__main__':`` block or moved to a separate file. Just make sure it's
not called because this will always start a local WSGI server which
we do not want if we deploy that application to uWSGI.
Starting your app with uwsgi
----------------------------
@ -50,7 +54,7 @@ A basic flask uWSGI configuration for nginx looks like this::
This configuration binds the application to `/yourapplication`. If you want
to have it in the URL root it's a bit simpler because you don't have to tell
it the WSGI `SCRIPT_NAME` or set the uwsgi modifer to make use of it::
it the WSGI `SCRIPT_NAME` or set the uwsgi modifier to make use of it::
location / { try_files $uri @yourapplication; }
location @yourapplication {
@ -58,6 +62,7 @@ it the WSGI `SCRIPT_NAME` or set the uwsgi modifer to make use of it::
uwsgi_pass unix:/tmp/uwsgi.sock;
}
.. _cherokee: http://www.cherokee-project.com/
.. _nginx: http://nginx.org/
.. _lighttpd: http://www.lighttpd.net/
.. _cherokee: http://www.cherokee-project.com/
.. _uwsgi: http://projects.unbit.it/uwsgi/