Skip to content

Instantly share code, notes, and snippets.

@alb-i986
Last active December 18, 2015 02:19
Show Gist options
  • Save alb-i986/5710593 to your computer and use it in GitHub Desktop.
Save alb-i986/5710593 to your computer and use it in GitHub Desktop.
uWSGI conf for Django apps with virtualenv. Designed for uWSGI Emperor, for a multi-app hosting server, with separate Dev/Test/Prod machines. Following the DRY principle, the directives are split in 3 files: - /etc/uwsgi/templates/base.conf - /etc/uwsgi/templates/include/vars.ini - /etc/uwsgi/templates/include/vars_shared.ini Then, in /etc/uwsgi…
[uwsgi]
proj_name = %n
# load variables
ini = /var/local/django/%n/uwsgi/vars.ini
ini = /etc/uwsgi/templates/include/vars.ini
ini = /etc/uwsgi/templates/include/vars-shared.ini
## DJANGO
virtualenv = /var/local/django/%n
# chdir = Django project's root
chdir = %(virtualenv)/src
module= wsgi:application
env = DJANGO_SETTINGS_MODULE=settings
## FASTROUTER
subscribe-to = 127.0.0.1:7000:%n.%(hostname).example.com
master
pidfile = %(uwsgi_pids_dir)/%n.pid
socket = %(uwsgi_sockets_dir)/%n.sock
daemonize = %(uwsgi_logs_dir)/%n.log
uid=django
gid=django
vacuum
limit-as=256
autoload
# Automatically make workers snapshot after reload
#auto-snapshot
## PROCESSES / THREADS
#listen = 4096
auto-procname
procname-append = _%n
processes=2
harakiri=20
enable-threads
threads = 5
# http://uwsgi-docs.readthedocs.org/en/latest/Options.html#max-requests
max-requests = 10000
memory-report
# http://uwsgi-docs.readthedocs.org/en/latest/Cheaper.html
# set cheaper algorithm to use, if not set default will be used
cheaper-algo = spare
# minimum number of workers to keep at all times
cheaper = 2
# number of workers to spawn at startup
cheaper-initial = 3
# maximum number of workers that can be spawned
workers = 3
# how many workers should be spawned at a time
cheaper-step = 1
cheaper-busyness-verbose # Enable verbose log messages from busyness algorithm
# idle: shuts down worker inactive for more than 1 hour
idle = 1800
## STATS
# http://uwsgi-docs.readthedocs.org/en/latest/StatsServer.html
stats-server = %(uwsgi_sockets_dir)/%n-stats.sock
#http://uwsgi-docs.readthedocs.org/en/latest/SNMP.html
#snmp = 127.0.0.1:2222
#snmp-community = foo
[uwsgi]
# any variable local to this single machine goes here
[uwsgi]
# this file is shared among all the 3 servers (dev/test/prod)
uwsgi_pids_dir = /var/run/uwsgi
uwsgi_sockets_dir = %(uwsgi_pids_dir)
uwsgi_logs_dir = /var/log/uwsgi
django_dir = /var/local/django
hostname = @(/etc/hostname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment