Software/

django-systemd

★ 1 stars ↓ 472 downloads

This is a django admin command that allows you to generate systemd unit files from templates using the django-render-static machinery. It also provides a thin layer on top of systemctl that allows discovery and basic management of the unit files associated with the installed django site environment.

This package makes it easy to do things like, provide a systemd service with your installable Django app or build a full gunicorn service from settings.

django-systemd

License: MIT Ruff PyPI version PyPI pyversions PyPI djversions PyPI status Documentation Status Code Cov Test Status Lint Status OpenSSF Scorecard

django-systemd does two independent things for a Django deployment:

  1. 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.
  2. Manage the project’s units. django-admin systemd can 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

See the documentation for the how-to and settings.