Files
led-controller/scripts/dev-run.sh
Jimmy 2382ef16a1 refactor(api): migrate server to fastapi and uvicorn
Replace the Microdot-only entrypoint with a CombinedASGI app that
handles FastAPI routes (audio API, websocket, dev live-reload) while
delegating the rest to Microdot. Suppress noisy /__dev/ access logs
during live-reload polling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 10:33:38 +12:00

21 lines
765 B
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
PORT="${PORT:-80}"
# On watchfiles restarts the previous process can linger briefly.
# Proactively terminate any listener on the target port before boot.
pids="$(ss -ltnp "sport = :$PORT" 2>/dev/null | sed -n 's/.*pid=\([0-9]\+\).*/\1/p' | sort -u)"
if [ -n "${pids}" ]; then
kill -TERM ${pids} 2>/dev/null || true
sleep 0.3
fi
cd "$ROOT_DIR/src"
exec env LED_CONTROLLER_LIVE_RELOAD=1 python -m uvicorn fastapi_app:app \
--host 0.0.0.0 --port "$PORT" --reload --reload-dir . \
--reload-include '**/*.html' --reload-include '**/*.css' --reload-include '**/*.js' \
--reload-exclude '**/db/**' --reload-exclude '**/settings.json' \
--reload-exclude '**/settings.json.*'