python_app – Manage NGINX Unit python application¶
Manage NGINX Unit python application configuration.
Upstream docs are at https://unit.nginx.org/configuration/#python.
Examples¶
- name: Create python 2 application
steampunk.unit.python_app:
name: demo
version: "2"
no_processes: 10
working_directory: /www/store/
path: /www/store/cart/
home: /www/store/.virtualenv/
module": wsgi
user": www
group": www
- name: Delete application
steampunk.unit.python_app:
name: demo
state: absent
Parameters¶
- environment (optional)
Environment variables to be passed to the application.
type: dict- group (optional)
Group name that runs the app process. If not set, the user’s primary group is used.
type: str- home (optional)
Virtual environment to use. Absolute, or relative to working_directory.
type: path- limits (optional)
Set the application’s lifecycle parameters.
Upstream documentation is available at https://unit.nginx.org/configuration/#configuration-proc-mgmt-lmts.
type: dict- requests (optional)
Maximum number of requests Unit allows an app process to serve. If the limit is reached, the process is restarted; this helps to mitigate possible memory leaks or other cumulative issues.
type: int- timeout (optional)
Request timeout in seconds. If an app process exceeds this limit while handling a request, Unit alerts it to cancel the request and returns an HTTP error to the client.
type: int
- module (optional)
WSGI module to run.
Required if state is
present
.type: str- name (required)
Application name.
type: str- no_processes (optional)
Number of processes that should be running at one time.
Mutually exclusive with processes.
Upstream documentation is available at https://unit.nginx.org/configuration/#configuration-proc-mgmt-prcs.
type: int- path (optional)
Additional lookup path for Python modules; this string is inserted into
sys.path
.type: str- processes (optional)
Dynamic process limits.
Mutually exclusive with no_processes.
Upstream documentation is available at https://unit.nginx.org/configuration/#configuration-proc-mgmt-prcs.
type: dict- idle_timeout (optional)
Time in seconds that Unit waits before terminating an idle process which exceeds spare.
type: int- max (optional)
Maximum number of application processes that Unit will maintain (busy and idle).
type: int- spare (optional)
Minimum number of idle processes that Unit tries to reserve for an app. When the app is started, spare idle processes are launched; Unit assigns incoming requests to existing idle processes, forking new idles to maintain the spare level if max allows. As processes complete requests and turn idle, Unit terminates extra ones after idle_timeout.
type: int
- provider (optional)
Connection parameters.
type: dict- ca_path (optional)
Path to the CA bundle that should be used to validate the backend certificate.
If this parameter is not set, module will use the CA bundle that python is using.
Can also be set using the UNIT_CA_PATH environment variable.
type: path- endpoint (optional)
HTTP or UNIX uri that should be used to communicate with the Unit.
The uri MUST be prefixed by either
http://
,https://
, orunix://
.By default, modules will try to connect to unix:///var/run/unit/control.sock, and if this socket does not exist, fallback to unix:///var/run/control.unit.sock.
Can also be set using the UNIT_ENDPOINT environment variable.
type: str- password (optional)
Password that is used when the endpoint is protected using the basic authentication.
This parameter is ignored when the enpoint parameter points to an unix socket.
Value is masked in the logs.
Can also be set using the UNIT_ENDPOINT environment variable.
type: str- username (optional)
Username that is used when the enpoint is protected using the basic authentication.
This parameter is ignored when the enpoint parameter points to an unix socket.
Can also be set using the UNIT_ENDPOINT environment variable.
type: str- verify (optional)
Flag that controls the certificate validation.
If you are using self-signed certificates, you can set this parameter to
false
.ONLY USE THIS PARAMETER IN DEVELOPMENT SCENARIOS! In you use self-signed certificates in production, see the auth.ca_path parameter.
Can also be set using the UNIT_VERIFY environment variable.
type: booldefault: True
- state (optional)
State of the manager resource.
type: strdefault: presentchoices: present, absent- user (optional)
Username that runs the app process. If not set, nobody is used.
type: str- version (optional)
Version of python module to use.
Use this module if you have more than one version of python module installed (eg. python 2 and python 3).
If this option is not set, unit will use the latest available module.
type: str- working_directory (optional)
The app’s working directory. If not set, the Unit daemon’s working directory is used.
type: path
Return Values¶
- object (On success and if I(state) == C(present)), dict, )
Object representing NGINX Unit Python application.
- name (always), str, )
Application name.
- limits (if set), dict, )
Set the application’s lifecycle parameters.
- timeout (), int, )
Request timeout in seconds.
- requests (), int, )
Maximum number of requests Unit allows an app to serve.
- no_processes (if set), int, )
Number of processes that should be running at one time.
- processes (if set), dict, )
Dynamic process limits.
- max (), int, )
Maximum number of application processes.
- spare (), int, )
Minimum number of idle processes.
- idle_timeout (), int, )
Time in seconds before terminating an idle process.
- working_directory (if set), str, )
The app’s working directory.
- user (if set), str, )
Username that runs the app process.
- group (if set), str, )
Group name that runs the app process.
- environment (if set), dict, )
Environment variables to be passed to the application.
- module (always), str, )
WSGI module to run.
- path (if set), str, )
Additional lookup path for Python modules.
- home (if set), str, )
Virtual environment in use.