Repository navigation
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·76 lines (62 loc) · 1.98 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·76 lines (62 loc) · 1.98 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVER_PORT="${SERVER_PORT:-8000}"
CLIENT_PORT="${CLIENT_PORT:-5173}"
SERVER_HOST="${SERVER_HOST:-127.0.0.1}"
CLIENT_HOST="${CLIENT_HOST:-127.0.0.1}"
# Let the server run the data-flow engine from engine/ source (see AGENTS.md "Engine").
export SRCLY_ENGINE_DEV="${SRCLY_ENGINE_DEV:-1}"
check_and_kill_port() {
port="$1"
if ! command -v lsof >/dev/null 2>&1; then
echo "Warning: 'lsof' not found, cannot check port $port."
return
fi
# Only match local listening processes. Plain `lsof -i :8000` can also match
# established outbound connections whose remote service name resolves to 8000.
pids="$(lsof -nP -tiTCP:"$port" -sTCP:LISTEN 2>/dev/null || true)"
if [ -n "$pids" ]; then
echo "Detected processes using port $port:"
lsof -nP -iTCP:"$port" -sTCP:LISTEN
printf "Do you want to kill these processes on port %s? [y/N] " "$port"
read ans
case "$ans" in
y|Y|yes|YES)
echo "$pids" | xargs -n1 kill -9
;;
*)
echo "Leaving processes on port $port running."
;;
esac
fi
}
cleanup() {
trap - INT TERM EXIT
if [ "${server_pid:-}" ]; then
kill "$server_pid" 2>/dev/null || true
fi
if [ "${client_pid:-}" ]; then
kill "$client_pid" 2>/dev/null || true
fi
wait 2>/dev/null || true
}
trap cleanup INT TERM EXIT
check_and_kill_port "$SERVER_PORT"
check_and_kill_port "$CLIENT_PORT"
echo "Starting API server on http://$SERVER_HOST:$SERVER_PORT"
(
cd "$ROOT_DIR/server"
uv run python -m uvicorn app.main:app --reload --timeout-graceful-shutdown 3 --host "$SERVER_HOST" --port "$SERVER_PORT"
) &
server_pid="$!"
echo "Starting Vite dev server on http://$CLIENT_HOST:$CLIENT_PORT"
(
cd "$ROOT_DIR/client"
pnpm run dev --host "$CLIENT_HOST" --port "$CLIENT_PORT"
) &
client_pid="$!"
while kill -0 "$server_pid" 2>/dev/null && kill -0 "$client_pid" 2>/dev/null; do
sleep 1
done
wait "$server_pid" "$client_pid"