diff --git a/py-dj.service b/py-dj.service new file mode 100644 index 0000000..ca10bf5 --- /dev/null +++ b/py-dj.service @@ -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 diff --git a/start-api.sh b/start-api.sh new file mode 100755 index 0000000..1710a0c --- /dev/null +++ b/start-api.sh @@ -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