Preset: Nice

This preset offers nice configuration defaults.

class uwsgiconf.presets.nice.Section(name=None, touch_reload=None, workers=None, threads=None, mules=None, owner=None, log_into=None, log_dedicated=None, process_prefix=None, ignore_write_errors=None, **kwargs)

Basic nice configuration.

Parameters:
  • name (str|unicode) – Section name.
  • touch_reload (str|list) – Reload uWSGI if the specified file or directory is modified/touched.
  • workers (int) – Spawn the specified number of workers (processes). Default: workers number equals to CPU count.
  • threads (int|bool) – Number of threads per worker or True to enable user-made threads support.
  • mules (int) – Number of mules to spawn.
  • owner (str|unicode) – Set process owner user and group.
  • log_into (str|unicode) – Filepath or UDP address to send logs into.
  • log_dedicated (bool) – If True all logging will be handled with a separate thread in master process.
  • process_prefix (str|unicode) – Add prefix to process names.
  • ignore_write_errors (bool) –

    If True no annoying SIGPIPE/write/writev errors will be logged, and no related exceptions will be raised.

    Note

    Usually such errors could be seen on client connection cancelling and are safe to ignore.

  • kwargs
get_log_format_default()

Returns default log message format.

Note

Some params may be missing.

classmethod get_bundled_static_path(filename)

Returns a full path to a static HTML page file bundled with uwsgiconf.

Parameters:filename (str) –

File name to return path to.

Examples:
  • 403.html
  • 404.html
  • 500.html
  • 503.html
Return type:str
configure_maintenance_mode(trigger, response)

Allows maintenance mode when a certain response is given for every request if a trigger is set.

Parameters:
  • trigger (str) – This triggers maintenance mode responses. Should be a path to a file: if file exists, maintenance mode is on.
  • response (str) –

    Response to to give in maintenance mode.

    Supported:
    • File path - this file will be served in response.
    • URLs starting with http - requests will be redirected there using 302. This is often discouraged, because it may have search ranking implications.
configure_owner(owner='www-data')

Shortcut to set process owner data.

Parameters:owner (str|unicode) – Sets user and group. Default: www-data.
configure_certbot_https(domain, webroot, address=None, allow_shared_sockets=None)

Enables HTTPS using certificates from Certbot https://certbot.eff.org.

Note

This relies on webroot mechanism of Certbot - https://certbot.eff.org/docs/using.html#webroot

Sample command to get a certificate: certbot certonly --webroot -w /webroot/path/ -d mydomain.org

Parameters:
  • domain (str) – Domain name certificates issued for (the same as in -d option in the above command).
  • webroot (str) – Directory to store challenge files to get and renew the certificate (the same as in -w option in the above command).
  • address (str) – Address to bind socket to.
  • allow_shared_sockets (bool) – Allows using shared sockets to bind to priviledged ports. If not provided automatic mode is enabled: shared are allowed if current user is not root.
class uwsgiconf.presets.nice.PythonSection(name=None, params_python=None, wsgi_module=None, wsgi_callable=None, embedded_plugins=True, require_app=True, threads=True, **kwargs)

Basic nice configuration using Python plugin.

Parameters:
  • name (str|unicode) – Section name.
  • params_python (dict) – See Python plugin basic params.
  • wsgi_module (str|unicode) –

    WSGI application module path or filepath.

    Example:
    mypackage.my_wsgi_module – read from application attr of mypackage/my_wsgi_module.py mypackage.my_wsgi_module:my_app – read from my_app attr of mypackage/my_wsgi_module.py
  • wsgi_callable (str|unicode|callable) – WSGI application callable name. Default: application.
  • embedded_plugins (bool|None) – This indicates whether plugins were embedded into uWSGI, which is the case if you have uWSGI from PyPI.
  • require_app (bool) – Exit if no app can be loaded.
  • threads (int|bool) – Number of threads per worker or True to enable user-made threads support.
  • kwargs