Skip to main content

https://github.com/idlesign/uwsgiconf

release lic ci coverage

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.

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

    """
    section = PythonSection(
        wsgi_module='/home/idle/myapp/wsgi.py',

    ).networking.register_socket(
        PythonSection.networking.sockets.http('127.0.0.1:8000'))

    return section


# 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:

    $ uwsgiconf run

Note: uwsgiconf CLI requires click package available (can be installed with uwsgiconf).

Runtime configuration

uwsgiconf comes with runtime package which is similar to uwsgidecorators but offers different abstractions.

These abstractions will also use a stub uwsgi module when the real one is not available.

A couple of examples:

from uwsgiconf.runtime.locking import lock
from uwsgiconf.runtime.scheduling import register_timer_rb

@register_timer_rb(10, repeat=2)
def repeat_twice():
    """This function will be called twice with 10 seconds interval
    (by default in first available mule) using red-black tree based timer.

    """
    with lock():
        # Code under this context manager will be locked
        # using default (0) uWSGI lock.
        do_something()

Third parties

Django. Run your Django-based project on uWSGI using manage command:

$ ./manage.py uwsgi_run
$ ./manage.py uwsgi_reload --force

Other commands are available.

System configs

Compile system service config (e.g systemd) to run your uWSGI-powered project:

$ uwsgiconf sysinit systemd

Documentation

More information can be found at http://uwsgiconf.readthedocs.org/

Release files for uwsgiconf 0.15.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uwsgiconf 0.15.3
File Size Uploaded
uwsgiconf-0.15.3.tar.gz 135.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uwsgiconf 0.15.3
File Interpreter ABI Platform
uwsgiconf-0.15.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 297.3 kB

Release files / uwsgiconf-0.15.3.tar.gz

Download URL uwsgiconf-0.15.3.tar.gz
Size 135.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e4de27d89c30d88fbfec0b0051d62d597e4be3cb46387a7840b796e08ef6aeae
BLAKE2b-256 checksum
How to use checksums
f9f8238a5ce520b94c56fe98ca21fc7b7cfc1e3aae41c6ac64d592c9726b3b0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release files / uwsgiconf-0.15.3-py2.py3-none-any.whl

Download URL uwsgiconf-0.15.3-py2.py3-none-any.whl
Size 162.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4b733250e9977775f692dafe6a16eb0557af8d01d990472b2548538b85c4a3b9
BLAKE2b-256 checksum
How to use checksums
eb3d2e055d43229fb1ff1ecae06ff9717a47cb67d14981cce0f1d24d64734103
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release history Release notifications | RSS feed

2.4.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.0

2 release files

This release

0.15.3 This release

2 release files

0.15.0

2 release files

0.14.2

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page