# {{ ansible_managed }}

description "Analytics server under gunicorn"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 3 30

env SERVICE_VARIANT={{ as_service_variant }}
env PID=/var/tmp/analytics.pid
env WORKERS={{ AS_WORKERS }}
env PORT={{ AS_SERVER_PORT }}
env LANG={{ AS_ENV_LANG }}
env DJANGO_SETTINGS_MODULE={{ as_django_settings }}

chdir {{ as_code_dir }}
setuid {{ as_web_user }}

exec {{ as_venv_dir }}/bin/gunicorn -b 0.0.0.0:$PORT -w $WORKERS --pythonpath={{ as_code_dir }}/anserv anserv.wsgi
