[uwsgi]
# Catch typos in configuration options
strict=true

# Basic environment
env=LANG=C.UTF-8
uid=zulip
gid=zulip

# Where the main application is located
chdir=/home/zulip/deployments/current/
module=zproject.wsgi:application

# Start a master process listening on this socket
master=true
chmod-socket=700
chown-socket=zulip:zulip
socket=/home/zulip/deployments/uwsgi-socket
listen=<%= @uwsgi_listen_backlog_limit %>

# Create a control socket, allowing fancier runtime control
master-fifo=/home/zulip/deployments/uwsgi-control


# Let threads run when processes aren't responding to requests;
# required for Sentry background worker
enable-threads=true

# How many serving processes to fork
processes=<%= @uwsgi_processes %>

# Give the processes short process names
auto-procname=true
procname-prefix-spaced=zulip-django

# Longest response allowed, in seconds, before killing the worker
harakiri=20



# Size of HTTP headers to read
buffer-size=<%= @uwsgi_buffer_size %>

# The master process will buffer requests with bodies longer than 4096
# bytes, freeing up workers from hanging around waiting to read them.
post-buffering=4096



# Create a socket to serve very basic UWSGI stats
stats=/home/zulip/deployments/uwsgi-stats


<% if @uwsgi_rolling_restart != '' -%>
# If we are doing a rolling restart, re-chdir to the current "current"
# directory in each forked process
hook-post-fork=chdir:/home/zulip/deployments/current

# lazy-apps are required for rolling restarts:
# https://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html#preforking-vs-lazy-apps-vs-lazy
lazy-apps=true



<% end -%>
# Silence warnings from clients closing their connection early
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true
