feat: add systemd scripts

This commit is contained in:
Radu C. Martin 2025-05-05 15:48:53 +02:00
parent d265b92f1d
commit 5666b87124
2 changed files with 27 additions and 0 deletions

13
py-dj.service Normal file
View file

@ -0,0 +1,13 @@
[Unit]
Description=Start py-dj FastAPI service
After=network.target
[Service]
User=pi
WorkingDirectory=/home/pi/py-dj
ExecStart=/home/pi/py-dj/start-api.sh
Restart=on-failure
Environment=PATH=/home/pi/.local/bin:/usr/bin:/bin
[Install]
WantedBy=multi-user.target

14
start-api.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
set -e
cd /home/pi/py-dj
# Pull latest changes
git pull
# Clear the queue directory
rm -rf queue/*
mkdir -p queue # Ensure it exists
# Start the API
uv run fastapi run