File size: 1,271 Bytes
8b3905d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Dev server with --reload scoped to app code only. Reloading on the repo root
# also watches .venv/site-packages and causes constant reload loops.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
export PYTHONPATH="$ROOT"
export PORT="${PORT:-8000}"

PYTHON="${ROOT}/.venv/bin/python"
if [[ ! -x "$PYTHON" ]]; then
  echo "Missing project venv. From repo root run:"
  echo "  python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt"
  exit 1
fi

if command -v lsof >/dev/null 2>&1; then
  if lsof -nP -iTCP:"$PORT" -sTCP:LISTEN >/dev/null 2>&1; then
    echo "Port $PORT is already in use — another process is listening."
    echo "Stop it (Ctrl+C in that terminal) or run on another port, e.g.:"
    echo "  PORT=8001 $0"
    exit 1
  fi
fi

echo "Starting SentinelAI API at http://127.0.0.1:${PORT} (reload dirs = source only)"
exec "$PYTHON" -m uvicorn backend.app.main:app \
  --reload \
  --host 0.0.0.0 \
  --port "$PORT" \
  --reload-dir "$ROOT/backend" \
  --reload-dir "$ROOT/agents" \
  --reload-dir "$ROOT/services" \
  --reload-dir "$ROOT/workflows" \
  --reload-dir "$ROOT/models" \
  --reload-dir "$ROOT/collectors" \
  --reload-dir "$ROOT/parsers" \
  --reload-dir "$ROOT/database"