import os import django.core.handlers.wsgi os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' application = django.core.handlers.wsgi.WSGIHandler()
Python applications can be deployed in many ways, be it using flup, FastCGI, SCGI, WSGI, etc. uWSGI is a feature rich, developer friendly application to do exactly that. It is a fast (pure C), self-healing, feature-rich WSGI server, aimed for professional python webapps deployment and development.
Cherokee offers native support for it. The configuration is quite easy, and uses the uWSGI handler.
To run Cherokee with uWSGI three simple steps will suffice:
You will need to complete a regular uWSGI installation
Add the produced binary into your PATH under the name "uwsgi"
Adapt your application to work with uWSGI.
Run the uWSGI Wizard provided by Cherokee and let it handle everything by itself.
The last step, configuring Cherokee, is trivial. The wizard will read the specified configuration file and will configure the web server accordingly.
Adapting your project is also fairly easy. For example, suppose you have a Django application which you want to adapt. You’ll have to create 2 configuration files on your django project directory.
We’ll call this one django_wsgi.py:
import os import django.core.handlers.wsgi os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' application = django.core.handlers.wsgi.WSGIHandler()
<uwsgi> <app mountpoint="/"> <script>project.django_wsgi</script> </app> </uwsgi>
The wizard will look for the uWSGI server, find out the mountpoint and configure the web server accordingly. Nothing more to do.