tkadkghdlf commited on
Commit
ff0e831
·
verified ·
1 Parent(s): e993245

Sync from GitHub via hub-sync

Browse files
Files changed (1) hide show
  1. deploy/huggingface/start-hf.sh +36 -0
deploy/huggingface/start-hf.sh CHANGED
@@ -19,6 +19,38 @@ start_bg() {
19
  PIDS+=("$!")
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  trap cleanup INT TERM EXIT
23
 
24
  # Hugging Face Docker Space starts this script as a normal process, but child
@@ -96,6 +128,10 @@ start_bg "auth-service" bash -c "cd /app/api/auth-service && exec \"${PYTHON_BIN
96
  start_bg "ai-service" bash -c "cd /app/api/ai-service && exec \"${PYTHON_BIN}\" -m uvicorn app.main:app --host 127.0.0.1 --port 8002"
97
  start_bg "api-gateway" bash -c "cd /app/api/api-gateway && exec \"${PYTHON_BIN}\" -m uvicorn app.main:app --host 127.0.0.1 --port 8000"
98
  start_bg "frontend" bash -c "cd /app/main && exec npm run start -- -H 127.0.0.1 -p 3000"
 
 
 
 
99
  start_bg "nginx" nginx -g "daemon off;"
100
 
101
  set +e
 
19
  PIDS+=("$!")
20
  }
21
 
22
+ wait_for_http() {
23
+ local name="$1"
24
+ local url="$2"
25
+ local timeout_sec="${3:-120}"
26
+ local started_at
27
+ started_at="$(date +%s)"
28
+
29
+ echo "Waiting for ${name} at ${url}..."
30
+ while true; do
31
+ if curl -fsS --max-time 2 "${url}" >/dev/null 2>&1; then
32
+ echo "${name} is ready."
33
+ return 0
34
+ fi
35
+
36
+ for pid in "${PIDS[@]}"; do
37
+ if ! kill -0 "${pid}" 2>/dev/null; then
38
+ echo "A service process exited before ${name} became ready." >&2
39
+ return 1
40
+ fi
41
+ done
42
+
43
+ local now
44
+ now="$(date +%s)"
45
+ if (( now - started_at >= timeout_sec )); then
46
+ echo "Timed out waiting for ${name} at ${url}." >&2
47
+ return 1
48
+ fi
49
+
50
+ sleep 1
51
+ done
52
+ }
53
+
54
  trap cleanup INT TERM EXIT
55
 
56
  # Hugging Face Docker Space starts this script as a normal process, but child
 
128
  start_bg "ai-service" bash -c "cd /app/api/ai-service && exec \"${PYTHON_BIN}\" -m uvicorn app.main:app --host 127.0.0.1 --port 8002"
129
  start_bg "api-gateway" bash -c "cd /app/api/api-gateway && exec \"${PYTHON_BIN}\" -m uvicorn app.main:app --host 127.0.0.1 --port 8000"
130
  start_bg "frontend" bash -c "cd /app/main && exec npm run start -- -H 127.0.0.1 -p 3000"
131
+
132
+ wait_for_http "frontend" "http://127.0.0.1:3000/" 120
133
+ wait_for_http "api-gateway" "http://127.0.0.1:8000/health" 60
134
+
135
  start_bg "nginx" nginx -g "daemon off;"
136
 
137
  set +e