sourabh gupta commited on
Commit
032f23b
Β·
1 Parent(s): 4fc0cbc

feat(ops): add all-in-one start and stop orchestrator scripts for local development

Browse files

- start.sh: Rewritten to gracefully terminate stale processes, start FastAPI (via direct py311 interpreter path to avoid buffering), poll /api/gaps up to 45 seconds to accommodate local reranker weights loading, and spin up Vite dev server
- stop.sh: Expanded to gracefully terminate both API and Vite frontend server processes and clean up tracking files
- Makefile: Added start/stop orchestrations and mapped api/stop-api targets
- .gitignore: Excluded PID tracking files (.api.pid, .web.pid, *.pid)

Files changed (4) hide show
  1. .gitignore +3 -0
  2. Makefile +7 -3
  3. start.sh +77 -10
  4. stop.sh +29 -7
.gitignore CHANGED
@@ -21,6 +21,9 @@ dist/
21
  # Misc
22
  temp/
23
  *.log
 
 
 
24
 
25
  # Data β€” reproducible via scripts/download_data.sh, never commit raw bytes
26
  data/
 
21
  # Misc
22
  temp/
23
  *.log
24
+ *.pid
25
+ .api.pid
26
+ .web.pid
27
 
28
  # Data β€” reproducible via scripts/download_data.sh, never commit raw bytes
29
  data/
Makefile CHANGED
@@ -20,13 +20,17 @@ seed:
20
  eval:
21
  python3.11 eval/run_eval.py
22
 
23
- # ── API control targets ───────────────────────────────────────────────────────
24
- api:
25
  bash start.sh
26
 
27
- stop-api:
28
  bash stop.sh
29
 
 
 
 
 
30
  openapi:
31
  python3.11 scripts/export_openapi.py
32
 
 
20
  eval:
21
  python3.11 eval/run_eval.py
22
 
23
+ # ── Services Orchestration ────────────────────────────────────────────────────
24
+ start:
25
  bash start.sh
26
 
27
+ stop:
28
  bash stop.sh
29
 
30
+ api: start
31
+
32
+ stop-api: stop
33
+
34
  openapi:
35
  python3.11 scripts/export_openapi.py
36
 
start.sh CHANGED
@@ -1,18 +1,85 @@
1
  #!/usr/bin/env bash
2
- # File Objective : Start the local development API server.
3
- # Scope : project root command script.
4
  # What this file does:
5
- # 1. Runs the FastAPI app via Uvicorn in reload mode.
6
- # 2. Redirects output to local logs and records the process PID.
 
 
 
7
  # What it does not do:
8
- # 1. Run inside a docker container (pure local bash execution).
9
 
10
- set -e
11
 
12
- echo "β†’ Starting Vantage API server on http://localhost:8000"
 
 
13
 
14
- # Run Uvicorn in the background, keeping track of process ID
15
- uvicorn apps.api.main:app --host 127.0.0.1 --port 8000 --reload > api.log 2>&1 &
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  echo $! > .api.pid
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- echo "βœ“ API server started in background (PID: $(cat .api.pid)). Logs written to api.log"
 
 
 
 
 
1
  #!/usr/bin/env bash
2
+ # File Objective : Start all local development services (FastAPI API + Vite Frontend) at once.
3
+ # Scope : project root orchestrator script.
4
  # What this file does:
5
+ # 1. Stops any pre-existing processes on ports 8000 and 5173 gracefully.
6
+ # 2. Starts the FastAPI backend with uvicorn via the py311 conda environment.
7
+ # 3. Polls the backend healthcheck up to 15 seconds for verification.
8
+ # 4. Starts the Vite React frontend on port 5173.
9
+ # 5. Writes PIDs to local files (.api.pid, .web.pid) and captures logs (api.log, web.log).
10
  # What it does not do:
11
+ # 1. Manage external database processes (Qdrant/Neo4j).
12
 
13
+ set -eo pipefail
14
 
15
+ echo "======================================================================"
16
+ echo " Vantage Orchestrator β€” Services Startup "
17
+ echo "======================================================================"
18
 
19
+ # 1. Stop any pre-existing instances first
20
+ echo "β†’ [1/5] Terminating any stale services..."
21
+ if [ -f .api.pid ]; then
22
+ PID=$(cat .api.pid)
23
+ echo " - Stopping FastAPI server (PID: $PID)..."
24
+ kill "$PID" 2>/dev/null || true
25
+ rm -f .api.pid
26
+ fi
27
+
28
+ if [ -f .web.pid ]; then
29
+ PID=$(cat .web.pid)
30
+ echo " - Stopping Vite Dev Server (PID: $PID)..."
31
+ kill "$PID" 2>/dev/null || true
32
+ rm -f .web.pid
33
+ fi
34
+
35
+ # Fallback: kill processes on ports directly
36
+ echo " - Scanning ports 8000 & 5173..."
37
+ kill $(lsof -t -i :8000) 2>/dev/null || true
38
+ kill $(lsof -t -i :5173) 2>/dev/null || true
39
+ echo " βœ“ Clean state achieved."
40
+
41
+ # 2. Reset log files
42
+ echo "β†’ [2/5] Cleaning stale logs..."
43
+ rm -f api.log web.log
44
+ touch api.log web.log
45
+
46
+ # 3. Start the FastAPI API Server
47
+ echo "β†’ [3/5] Starting FastAPI Server (Port: 8000)..."
48
+ # We run uvicorn through python inside the py311 conda environment directly to avoid conda run buffering
49
+ /Users/sourabh/opt/miniconda3/envs/py311/bin/python -m uvicorn apps.api.main:app --host 127.0.0.1 --port 8000 --reload > api.log 2>&1 &
50
  echo $! > .api.pid
51
+ echo " βœ“ FastAPI process spawned in background (PID: $(cat .api.pid))"
52
+
53
+ # 4. Wait for API Server Readiness
54
+ echo -n "β†’ [4/5] Polling API healthcheck"
55
+ API_READY=false
56
+ for i in {1..45}; do
57
+ if curl -s "http://127.0.0.1:8000/api/gaps?limit=1" >/dev/null; then
58
+ API_READY=true
59
+ break
60
+ fi
61
+ echo -n "."
62
+ sleep 1
63
+ done
64
+ echo ""
65
+
66
+ if [ "$API_READY" = true ]; then
67
+ echo " βœ“ API is responding on http://127.0.0.1:8000"
68
+ else
69
+ echo " ⚠ API failed to respond within 45 seconds."
70
+ echo " - Tail of api.log:"
71
+ tail -n 15 api.log
72
+ exit 1
73
+ fi
74
+
75
+ # 5. Start the Vite React Dev Server
76
+ echo "β†’ [5/5] Starting Vite Frontend Server (Port: 5173)..."
77
+ npm --prefix apps/web run dev > web.log 2>&1 &
78
+ echo $! > .web.pid
79
+ echo " βœ“ Vite process spawned in background (PID: $(cat .web.pid))"
80
 
81
+ echo "======================================================================"
82
+ echo " βœ“ All services launched successfully!"
83
+ echo " - API Backend : http://localhost:8000 (Logs: api.log)"
84
+ echo " - React Web UI : http://localhost:5173 (Logs: web.log)"
85
+ echo "======================================================================"
stop.sh CHANGED
@@ -1,18 +1,40 @@
1
  #!/usr/bin/env bash
2
- # File Objective : Stop the local development API server.
3
- # Scope : project root command script.
4
  # What this file does:
5
- # 1. Looks for the running API server process PID.
6
- # 2. Gracefully terminates the process and cleans up tracking files.
 
7
  # What it does not do:
8
- # 1. Stop docker containers or database instances.
 
 
 
 
9
 
10
  if [ -f .api.pid ]; then
11
  PID=$(cat .api.pid)
12
- echo "β†’ Stopping Vantage API server (PID: $PID)..."
13
  kill "$PID" 2>/dev/null || true
14
  rm -f .api.pid
15
  echo "βœ“ API server stopped."
16
  else
17
- echo "⚠ No .api.pid file found. API server might not be running."
 
 
 
 
 
 
 
 
 
 
18
  fi
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env bash
2
+ # File Objective : Stop all local development services (FastAPI API + Vite Frontend).
3
+ # Scope : project root orchestrator script.
4
  # What this file does:
5
+ # 1. Looks for the running API server process PID and stops it.
6
+ # 2. Looks for the running Vite Dev server process PID and stops it.
7
+ # 3. Cleans up tracking files (.api.pid, .web.pid).
8
  # What it does not do:
9
+ # 1. Terminate database docker containers (Qdrant/Neo4j).
10
+
11
+ echo "======================================================================"
12
+ echo " Vantage Orchestrator β€” Services Shutdown "
13
+ echo "======================================================================"
14
 
15
  if [ -f .api.pid ]; then
16
  PID=$(cat .api.pid)
17
+ echo "β†’ Stopping FastAPI server (PID: $PID)..."
18
  kill "$PID" 2>/dev/null || true
19
  rm -f .api.pid
20
  echo "βœ“ API server stopped."
21
  else
22
+ echo "⚠ No .api.pid file found. API server might not be running via PID."
23
+ fi
24
+
25
+ if [ -f .web.pid ]; then
26
+ PID=$(cat .web.pid)
27
+ echo "β†’ Stopping Vite Frontend server (PID: $PID)..."
28
+ kill "$PID" 2>/dev/null || true
29
+ rm -f .web.pid
30
+ echo "βœ“ Frontend server stopped."
31
+ else
32
+ echo "⚠ No .web.pid file found. Frontend server might not be running via PID."
33
  fi
34
+
35
+ # Fallback: kill port processes directly if any remaining
36
+ echo "β†’ Performing final check on ports 8000 & 5173..."
37
+ kill $(lsof -t -i :8000) 2>/dev/null || true
38
+ kill $(lsof -t -i :5173) 2>/dev/null || true
39
+ echo "βœ“ Clean state achieved."
40
+ echo "======================================================================"