Configure uWSGI from your Python code
Project description
https://github.com/idlesign/uwsgiconf
Work in progress. Stay tuned.
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.
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?
Usage Strategies
Two main strategies to use uwsgiconf:
Static: create configuration .py and compile it when you like into classic uWSGI .ini using provided methods.
Dynamic: create configuration .py, and give it directly to uWSGI with exec directive.
uwsgiconf CLI has tools to streamline both of these.
A taste of it
Let’s make uwsgicfg.py. There we configure it using nice PythonSection preset to run our web app.
from uwsgiconf.presets.nice import PythonSection
configuration = PythonSection(
# Load wsgi.py module containing WSGI application.
wsgi_module='/home/idle/myapp/wsgi.py',
).networking.register_socket(
# Make app available at http://127.0.0.1:8000
address='127.0.0.1:8000',
type=PythonSection.networking.socket_types.HTTP,
).as_configuration()
configuration.print_ini()
Now if you want to generate myconf.ini file and use it for uWSGI you can do it with:
$ python uwsgicfg.py > myconf.ini ; or just $ uwsgiconf compile > myconf.ini $ uwsgi myconf.ini
Or for dynamic usage of .py:
$ uwsgi --ini "exec://python uwsgicfg.py" ; or just $ uwsgiconf run
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for uwsgiconf-0.9.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bb7f3adbe640c0ac4af89a49046d682c10e4a46cf6f704dbe1ea8fd75716bda |
|
MD5 | efda6ad8fd92f64eddde6578fead5dbb |
|
BLAKE2b-256 | 5d0e63e4a9652b7bfa142162cb112d003886da7533daea66467337ded411aedc |