[fcgi-program:asgi]
# Define Tethys Home
environment=
    TETHYS_HOME={{ tethys_home }}

# TCP socket used by Nginx backend upstream
socket=tcp://127.0.0.1:{{ port }}

# Project files directory location
directory={{ tethys_src }}

# Each process needs to have a separate socket file, so we use process_num
command=bash -c "{% if not is_micromamba %}source {{ conda_home }}/bin/activate {{ conda_env_name}} && {% endif %}{{ conda_prefix }}/bin/daphne -u /run/tethys_asgi%(process_num)d.sock --fd 0 --access-log - --proxy-headers tethys_portal.asgi:application"

# Number of processes to startup, roughly the number of CPUs you have
numprocs={{ asgi_processes }}

# Give each process a unique name so they can be told apart
process_name=tethys_asgi%(process_num)d

# Automatically start and recover processes
autostart=true
autorestart=true

#Ensure process is killed correctly
stopasgroup=true
stopsignal=QUIT

# Choose where you want your log to go
stdout_logfile=/var/log/tethys/tethys.log
redirect_stderr=true