Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
89 lines (78 loc) · 2.66 KB
/
Copy pathrun.sh
File metadata and controls
89 lines (78 loc) · 2.66 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# ============================================================
# OpenStreamRotatorWeb — Run
# Starts both the backend and frontend.
# Backend runs in the background, frontend in the foreground.
# Press Ctrl+C to stop both.
# ============================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo ""
echo " =========================================="
echo " OpenStreamRotatorWeb - Starting Services"
echo " =========================================="
echo ""
# ----------------------------------------------------------
# Pre-flight checks
# ----------------------------------------------------------
if [ ! -f "backend/.env" ]; then
echo " ERROR: backend/.env not found."
echo " Run ./setup.sh first to configure the dashboard."
echo ""
exit 1
fi
if [ ! -d "backend/.venv" ]; then
echo " ERROR: backend virtual environment not found."
echo " Run ./setup.sh first, or manually create it:"
echo " cd backend && python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt"
echo ""
exit 1
fi
if [ ! -d "frontend/node_modules" ]; then
echo " ERROR: frontend/node_modules not found."
echo " Run ./setup.sh first, or manually install:"
echo " cd frontend && npm install"
echo ""
exit 1
fi
# ----------------------------------------------------------
# Cleanup on exit — kill backend when frontend stops
# ----------------------------------------------------------
BACKEND_PID=""
cleanup() {
echo ""
echo " Shutting down..."
if [ -n "$BACKEND_PID" ] && kill -0 "$BACKEND_PID" 2>/dev/null; then
kill "$BACKEND_PID" 2>/dev/null
wait "$BACKEND_PID" 2>/dev/null
fi
echo " All services stopped."
}
trap cleanup EXIT INT TERM
# ----------------------------------------------------------
# Run migrations
# ----------------------------------------------------------
echo " Running database migrations..."
cd backend
source .venv/bin/activate
python -m alembic upgrade head 2>&1 | tail -1
echo ""
# ----------------------------------------------------------
# Start backend in background
# ----------------------------------------------------------
echo " Starting backend on http://localhost:8000..."
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload &
BACKEND_PID=$!
cd ..
# Give the backend a moment to start
sleep 2
# ----------------------------------------------------------
# Start frontend in foreground
# ----------------------------------------------------------
echo " Starting frontend on http://localhost:3000..."
echo ""
echo " Press Ctrl+C to stop both services."
echo ""
cd frontend
npm run dev