uWSGI seemingly can do a bit of everything, but covering that is a job for the uWSGI documentation. This page covers some basic configuration tasks that may be required just to get your application running, and other tricks you should consider.
If your Python application needs to start within a particular
directory, use the uWSGI --chdir /starting/path
command-line
option or chdir = /starting/path
in your .ini
file.
If your Python application needs to run within a virtualenv,
and you didn't already activate that virtualenv to run uWSGI
itself, point to the virtualenv with the uWSGI -H
command-line option or with virtualenv = /path/to/virtualenv
in your .ini
file.
uWSGI command-line invocation: --env varname=value
.ini
file: env varname=value
If the application hangs while processing a request, you can configure
uWSGI to destroy the application process handling the request after a timeout
using the -t seconds
command-line option or
harakiri = seconds
in your .ini
file.
Some uWSGI configuration examples show this timeout specified without any advice. Consider the following before setting it:
I don't think that processing is helpful for many applications. Refer to the uWSGI FAQ entry on Harakiri mode for more information.
uWSGI can provide statistics in JSON format over a socket, and provides a tool called uwsgitop to maintain a display of activity.
Add stats = 127.0.0.1:port-number
to your
.ini
file, then access the stats as follows using netcat
or uwsgitop:
$ nc 127.0.0.1 9191 { "version":"2.0.5", "listen_queue":0, "listen_queue_errors":0, "signal_queue":0, "load":0, "pid":14600, "uid":1, "gid":1, "cwd":"/home/trawick/myhg/projects/pyweb/app/wsgi", "locks":[ ... $ uwsgitop 127.0.0.1:9191 uwsgi-2.0.5 - Sun May 18 16:00:49 2014 - req: 778571 - RPS: 5291 - lq: 0 - tx: 51.0G node: trawick-ip - cwd: /home/trawick/myhg/projects/pyweb/app/wsgi - uid: 1 - gid: 1 - masterpid: 14760 WID % PID REQ RPS EXC SIG STATUS AVG RSS VSZ TX RunT 1 14.0 14766 108708 753 0 0 idle 0ms 0 0 7.0G 22275 2 16.0 14767 124356 868 0 0 idle 0ms 0 0 8.0G 25575 4 30.4 14769 236788 1596 0 0 busy 0ms 0 0 15.0G 49106 3 39.7 14768 308719 2074 0 0 busy 0ms 0 0 20.0G 64232