40 lines
1.4 KiB
Desktop File
40 lines
1.4 KiB
Desktop File
# Prod web process: gunicorn master + uvicorn ASGI workers, behind Caddy.
|
|
#
|
|
# `systemctl reload polylan-submitter` sends HUP to the gunicorn master: it
|
|
# keeps the :7777 socket open, boots new workers on the new code, then
|
|
# gracefully stops the old ones - no downtime. See deploy/systemd/deploy.sh.
|
|
#
|
|
# Installed to /etc/systemd/system/ by deploy.sh: when this file changed it
|
|
# does daemon-reload + a full restart (HUP keeps the old ExecStart args).
|
|
|
|
[Unit]
|
|
Description=PolyLAN submitter (gunicorn + uvicorn workers)
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
Restart=always
|
|
RestartSec=1
|
|
User=root
|
|
WorkingDirectory=/home/caddy/polylan-submitter/polylan_submitter
|
|
# Relative to WorkingDirectory, loaded by settings.py via python-dotenv.
|
|
Environment="SETTINGS_ENV_FILE_LOCATION=polylan_submitter/.env"
|
|
|
|
# No --preload: with it, HUP re-forks from the already imported (old) code.
|
|
# --forwarded-allow-ips replaces daphne's --proxy-headers: trust
|
|
# X-Forwarded-* only from Caddy (local here).
|
|
ExecStart=/home/caddy/polylan-submitter/.venv/bin/gunicorn polylan_submitter.asgi:application \
|
|
--worker-class uvicorn_worker.UvicornWorker \
|
|
--workers 2 \
|
|
--bind 0.0.0.0:7777 \
|
|
--graceful-timeout 20 \
|
|
--forwarded-allow-ips 127.0.0.1
|
|
ExecReload=/bin/kill -s HUP $MAINPID
|
|
|
|
# SIGTERM to the master only, it then drains its workers (graceful-timeout).
|
|
KillMode=mixed
|
|
TimeoutStopSec=30
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|