-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·49 lines (41 loc) · 1.11 KB
/
run.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.11 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
#!/usr/bin/env bash
ROOT="$(cd "$(dirname "$0")" && pwd)"
BACKEND_PID=""
FRONTEND_PID=""
cleanup() {
printf "\nStopping backend and frontend...\n"
[ -n "$BACKEND_PID" ] && kill "$BACKEND_PID" 2>/dev/null || true
[ -n "$FRONTEND_PID" ] && kill "$FRONTEND_PID" 2>/dev/null || true
exit 0
}
trap cleanup INT TERM
# Free ports 8000 and 3000 if in use (e.g. from a previous run)
for port in 8000 3000; do
for pid in $(lsof -ti:"$port" 2>/dev/null); do
kill -9 "$pid" 2>/dev/null && echo "Killed process $pid on port $port" || true
done
done
sleep 1
cd "$ROOT/backend"
if [ -d "venv" ]; then
source venv/bin/activate
fi
uvicorn app.main:app --reload --port 8000 &
BACKEND_PID=$!
# Prefer Node 18+ for Next.js 14
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
if [ -s "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh"
nvm use 18 2>/dev/null || nvm use 20 2>/dev/null || nvm use 22 2>/dev/null || nvm use 2>/dev/null || true
fi
cd "$ROOT/frontend"
npm run dev &
FRONTEND_PID=$!
sleep 2
echo ""
echo "Backend: http://localhost:8000"
echo "Frontend: http://localhost:3000"
echo ""
echo "Press Ctrl+C to stop both."
echo ""
wait