Django Systemd¶
django-systemd does two independent things for a Django deployment:
Generate systemd unit files. Apps bundle unit templates in a systemd/ directory. Render them at package time with known settings and commit the result, or render them at deploy time from live production settings. This allows you to do things like ship services with your reusable Django app that downstream users can deploy from their own settings.
Manage the project’s units.
systemdcan list, install, update, restart and reload every unit the project defines, without you naming them. Units are managed in the system scope by default; privileges come from root, an explicit escalation prefix, or polkit with the link install method. The user scope, with nothing running as root, is still available.
django-admin systemd list
django-admin systemd render ./units --context venv=/srv/app/.venv # in CI
django-admin systemd install --enable # on the host
django-admin systemd reload # on the host