Adding deployment to raspberrypi

This commit is contained in:
2026-03-17 16:53:19 -07:00
parent 51717b3d6f
commit 437ee886b7
7 changed files with 135 additions and 51 deletions

41
scripts/setup_service.sh Normal file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
set -e
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
SERVICE_NAME="birdcam"
USER="$(whoami)"
VENV_PYTHON="$(poetry env info --path)/bin/python"
GUNICORN="$(poetry env info --path)/bin/gunicorn"
echo "Installing systemd service..."
sudo tee /etc/systemd/system/${SERVICE_NAME}.service > /dev/null <<EOF
[Unit]
Description=Birdcam Flask Application
After=network.target
[Service]
User=${USER}
WorkingDirectory=${REPO_DIR}
ExecStart=${GUNICORN} \
--workers 2 \
--worker-class gthread \
--threads 4 \
--bind 127.0.0.1:8000 \
--access-logfile - \
--error-logfile - \
"src.app:app"
Restart=on-failure
RestartSec=5
Environment=PYTHONPATH=${REPO_DIR}
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager
echo "Service installed and started."