-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwait.sh
More file actions
executable file
·49 lines (37 loc) · 968 Bytes
/
wait.sh
File metadata and controls
executable file
·49 lines (37 loc) · 968 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# ./wait-for-tei.sh http://X.X.X.X:8080
# or
# ./wait-for-tei.sh X.X.X.X:8080
TARGET="${1:-}"
TIMEOUT=300 # 5 minutes in seconds
INTERVAL=1 # seconds
if [[ -z "$TARGET" ]]; then
echo "Usage: $0 <host:port | url>"
exit 2
fi
# Normalize input
if [[ "$TARGET" != http* ]]; then
BASE_URL="http://$TARGET"
else
BASE_URL="$TARGET"
fi
ENDPOINT="$BASE_URL/health"
START_TIME=$(date +%s)
echo "Waiting for TEI health at $ENDPOINT (timeout: ${TIMEOUT}s)"
while true; do
NOW=$(date +%s)
ELAPSED=$((NOW - START_TIME))
if (( ELAPSED >= TIMEOUT )); then
echo "❌ Timed out after ${TIMEOUT}s waiting for TEI health"
exit 1
fi
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$ENDPOINT" || true)
if [[ "$HTTP_CODE" == "200" ]]; then
echo "✅ TEI is healthy (HTTP 200)"
exit 0
fi
echo "⏳ Not ready yet (HTTP $HTTP_CODE) — ${ELAPSED}s elapsed"
sleep "$INTERVAL"
done