[systemd] Add django service
This commit is contained in:
15
PROJECT.org
15
PROJECT.org
@ -1,5 +1,20 @@
|
|||||||
#+title: Project
|
#+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
|
* Backlog
|
||||||
** DONE Figure out why SSH key loading isn't working in terminal Emacs :personal:bug:dotfiles:emacs:ssh:
|
** DONE Figure out why SSH key loading isn't working in terminal Emacs :personal:bug:dotfiles:emacs:ssh:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
|||||||
17
systemd/.config/systemd/user/django@.service
Normal file
17
systemd/.config/systemd/user/django@.service
Normal file
@ -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
|
||||||
Reference in New Issue
Block a user