-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-dev.sh
More file actions
executable file
·89 lines (72 loc) · 1.78 KB
/
Copy pathrun-dev.sh
File metadata and controls
executable file
·89 lines (72 loc) · 1.78 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
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HUB_DIR="$ROOT_DIR/modules/hub"
ENV_FILE="$ROOT_DIR/.env"
SERVER_PID=""
if [[ -f "$ENV_FILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
else
echo "Missing .env at repo root. Copy .env.example to .env and edit it." >&2
exit 1
fi
export HUB_BIND_ADDR="${HUB_BIND_ADDR:-0.0.0.0:8080}"
server_url() {
printf 'http://%s\n' "$HUB_BIND_ADDR"
}
wait_for_server() {
local url
url="$(server_url)"
for _ in {1..120}; do
if curl -fsS "$url/health" >/dev/null 2>&1; then
echo "Health check passed: $url/health"
return 0
fi
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
wait "$SERVER_PID"
return $?
fi
sleep 0.25
done
echo "Pascal hub did not become healthy at $url/health" >&2
return 1
}
stop_server() {
if [[ -z "$SERVER_PID" ]] || ! kill -0 "$SERVER_PID" 2>/dev/null; then
return
fi
echo
echo "Stopping Pascal hub..."
kill -TERM "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
}
cleanup() {
local status=$?
trap - EXIT INT TERM
stop_server
exit "$status"
}
trap cleanup EXIT INT TERM
(
cd "$HUB_DIR"
uv sync
exec uv run hub-server
) &
SERVER_PID=$!
echo "Pascal hub PID: $SERVER_PID"
wait_for_server
url="$(server_url)"
echo
echo "Pascal hub is running with only:"
echo " MCP endpoint: $url/mcp"
echo " WebRTC offer URL: $url/v1/webrtc/offer"
echo " ESP log URL: $url/v1/logs"
echo " Health check: $url/health"
echo " Snapshot file: ${HUB_SNAPSHOT_PATH:-${HUB_DATA_DIR:-/tmp/pascal}/latest.jpg}"
echo
echo "The Swift app should use HUB_IOS_SERVER_URL=$url, or another LAN-reachable URL."
echo "Press Ctrl-C to stop."
wait "$SERVER_PID"