Configure uWSGI from your Python code

Project description

https://github.com/idlesign/uwsgiconf

Description

Configure uWSGI from your Python code

If you think you know uWSGI you’re probably wrong. It is always more than you think it is. There are so many subsystems and options (800+) it is difficult to even try to wrap your mind around.

uwsgiconf allowing to define uWSGI configurations in Python tries to improve things the following ways:

• It structures options for various subsystems using classes and methods;

• It uses docstrings and sane naming to facilitate navigation;

• It ships some useful presets to reduce boilerplate code;

• It encourages configuration reuse;

• It comes with CLI to facilitate configuration;

• It features easy to use and documented uwsgi stub Python module;

• It offers runtime package, similar to uwsgidecorators, but with more abstractions;

• It features integration with Django Framework;

• It is able to generate configuration files for Systemd, Upstart.

• It can use pyuwsgi.

Consider using IDE with autocompletion and docstings support to be more productive with uwsgiconf.

By that time you already know that uwsgiconf is just another configuration method. Why?

Overview

Static configuration

Let’s make uwsgicfg.py. There we configure uWSGI using nice PythonSection preset to run our web app.

from uwsgiconf.config import configure_uwsgi
from uwsgiconf.presets.nice import PythonSection

def get_configurations():
"""This should return one or more Section or Configuration objects.
In such a way you can configure more than one uWSGI instance in the same place.

Here we'll define just one configuration section, which
will instruct uWSGI to serve WSGI application (from wsgi.py module)
on http://127.0.0.1:8000. We use .bootstrap shortcut method
to construct out configuration section object.

"""
return PythonSection.bootstrap('http://127.0.0.1:8000', wsgi_module='/home/idle/myapp/wsgi.py')

# Almost done. One more thing:
configure_uwsgi(get_configurations)
1. Now if you want to generate myconf.ini file and use it for uWSGI manually you can do it with:

$uwsgiconf compile > myconf.ini$ uwsgi myconf.ini
2. Or use uwsgiconf to automatically spawn uWSGI processes for configurations defined in your module:

Project details

Uploaded source
Uploaded 2 7