uwsgi is a Python wsgi server which speaks a custom wire protocol upstream. uwsgi is configured through its command line interface and breaks many useful tuning parameters out into simple command line options.

Installation

Compiling uwsgi

Go to uwsgi's site and download the lastest stable source tarball.

On debian, you'll need build-essential and libxml2-dev:

# aptitude install build-essential libxml2-dev

Untar, then compile with make:

$ tar xvfz uwsgi-0.9.6.9.tar.gz
$ cd uwsgi-0.9.6.9
$ make

Uwsgi has no install make target, so just move the binary to /opt:

# mkdir -p /opt/uwsgi/uwsgi-0.9.6.9
# mv uwsgi /opt/uwsgi/uwsgi-0.9.6.9
# cd /opt/uwsgi
# ln -s uwsgi-0.9.6.9 current

Be sure to use the complete path to uwsgi, /opt/uwsgi/current/uwsgi unless you add /opt/uwsgi/current to your path.

Obtaining nginx 0.8 for uwsgi support

uwsgi configuration

Daemontools

uwsgi.ini
run script

#!/bin/bash

UWSGI=/opt/uwsgi/current/uwsgi
export PYTHON_EGG_CACHE=/tmp
export PLACES_CONFIG=$(pwd)/places_api.conf

exec 2>&1 
exec setuidgid www-data ${UWSGI} --ini uwsgi.ini

SIGTERM

Note that uwsgi handles SIGTERM strangely, so the usual patterns of using svc -d and svc -t to take down and reload the uwsgi daemon will not work. Instead, send SIGINT:

# svc -i /etc/service/my-uwsgi-project # reloads project

# svc -d /etc/service/my-uwsgi-project # sets project to be "down," but will hang
# svc -i /etc/service/my-uwsgi-project # reloads project, leaving it down

Nginx configuration

  • upstream
  • uwsgi_params
  • uwsgi_pass

http://projects.unbit.it/uwsgi/browser/nginx/uwsgi_params