[uwsgi]

socket = :8000
chdir = /srv/app/
module = wsgi
touch-reload = /srv/app/wsgi.py
chmod-socket = 664

uid = www-data
gid = www-data

strict = true
master = true
enable-threads = false
vacuum = true                        ; Delete sockets during shutdown
single-interpreter = true
die-on-term = true                   ; Shutdown when receiving SIGTERM (default is respawn)
need-app = true

disable-logging = false               ; Disable built-in logging
#log-4xx = true                       ; but log 4xx's anyway
#log-5xx = true                       ; and 5xx's
logger = file:/var/log/app/app.log

harakiri = 60                        ; forcefully kill workers after 60 seconds
#py-callos-afterfork = true           ; allow workers to trap signals

max-requests = 10000                 ; Restart workers after this many requests
max-worker-lifetime = 3600           ; Restart workers after this many seconds
reload-on-rss = 2048                 ; Restart workers after this much resident memory
worker-reload-mercy = 60             ; How long to wait before forcefully killing workers

cheaper-algo = busyness
processes = 16                       ; Maximum number of workers allowed
cheaper = 8                          ; Minimum number of workers allowed
cheaper-initial = 8                  ; Workers created at startup
cheaper-overload = 1                 ; Length of a cycle in seconds
cheaper-step = 2                     ; How many workers to spawn at a time

cheaper-busyness-multiplier = 30     ; How many cycles to wait before killing workers
cheaper-busyness-min = 20            ; Below this threshold, kill workers (if stable for multiplier cycles)
cheaper-busyness-max = 70            ; Above this threshold, spawn new workers
cheaper-busyness-backlog-alert = 10  ; Spawn emergency workers if more than this many requests are waiting in the queue
cheaper-busyness-backlog-step = 2    ; How many emergency workers to create if there are too many requests in the queue


