-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-chief.command
More file actions
executable file
·86 lines (70 loc) · 2.02 KB
/
start-chief.command
File metadata and controls
executable file
·86 lines (70 loc) · 2.02 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
#!/bin/bash
# ─────────────────────────────────────────────────────
# CHIEF — macOS Launcher
# Double-click from Finder to start both servers.
# ─────────────────────────────────────────────────────
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
GREEN='\033[0;32m'
DIM='\033[2m'
RESET='\033[0m'
echo ""
echo -e "${GREEN}CHIEF${RESET} — starting backend + frontend..."
echo ""
BACKEND_PID=""
FRONTEND_PID=""
cleanup() {
echo ""
echo -e "${DIM}Shutting down...${RESET}"
[ -n "$BACKEND_PID" ] && kill "$BACKEND_PID" 2>/dev/null
[ -n "$FRONTEND_PID" ] && kill "$FRONTEND_PID" 2>/dev/null
wait 2>/dev/null
echo -e "${GREEN}Done.${RESET}"
exit 0
}
trap cleanup SIGINT SIGTERM EXIT
# ── Backend ──
echo -e "${DIM}Starting backend (port 8000)...${RESET}"
(
cd "$SCRIPT_DIR/backend"
source .venv/bin/activate 2>/dev/null || true
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
) &
BACKEND_PID=$!
# ── Frontend ──
echo -e "${DIM}Starting frontend (port 3000)...${RESET}"
(
cd "$SCRIPT_DIR/frontend"
pnpm dev
) &
FRONTEND_PID=$!
# ── Wait for readiness ──
echo -e "${DIM}Waiting for servers...${RESET}"
wait_for_port() {
local port=$1
local attempt=0
while ! curl -sf "http://localhost:$port" > /dev/null 2>&1; do
attempt=$((attempt + 1))
if [ $attempt -ge 60 ]; then
echo -e "Timed out waiting for port $port"
return 1
fi
sleep 1
done
}
wait_for_port 8000 &
W1=$!
wait_for_port 3000 &
W2=$!
wait $W1 $W2
echo ""
echo -e "${GREEN}Both servers ready.${RESET} Opening browser..."
echo ""
open "http://localhost:3000"
echo -e " Backend: ${DIM}http://localhost:8000${RESET}"
echo -e " Frontend: ${GREEN}http://localhost:3000${RESET}"
echo ""
echo -e " ${DIM}Press Ctrl+C to stop both servers.${RESET}"
echo ""
wait