From 43f66257566e287d9dd0e328ac6797060a9974df Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 8 Mar 2026 17:50:03 -0400 Subject: [PATCH] [systemd] Add django service --- PROJECT.org | 15 +++++++++++++++ systemd/.config/systemd/user/django@.service | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 systemd/.config/systemd/user/django@.service diff --git a/PROJECT.org b/PROJECT.org index 38bd0ea..d9ae966 100644 --- a/PROJECT.org +++ b/PROJECT.org @@ -1,5 +1,20 @@ #+title: Project +* Notes +** Django projects +For running Django projects in the background, add an environment file to ~/.local/etc/project.env with contents like: + +#+begin_src shell +DJANGO_PATH="/home/user/src/project" +DJANGO_PORT=8000 +#+end_src + +Then enable now the project: + +#+begin_src shell +sysu enable --now django@project +#+end_src + * Backlog ** DONE Figure out why SSH key loading isn't working in terminal Emacs :personal:bug:dotfiles:emacs:ssh: :PROPERTIES: diff --git a/systemd/.config/systemd/user/django@.service b/systemd/.config/systemd/user/django@.service new file mode 100644 index 0000000..84c1d83 --- /dev/null +++ b/systemd/.config/systemd/user/django@.service @@ -0,0 +1,17 @@ +[Unit] +Description=Django dev server for %I +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +Environment=PATH=%h/.local/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin +EnvironmentFile=%h/.local/etc/django/%i.env +ExecStart=/bin/bash -c 'cd "$DJANGO_PATH" && exec direnv exec "$DJANGO_PATH" poetry run python -u manage.py runserver 0.0.0.0:${DJANGO_PORT:-8000}' +Restart=on-failure +RestartSec=2 +StandardOutput=append:/tmp/django.log +StandardError=inherit + +[Install] +WantedBy=default.target