#!/bin/sh # Waits until GET /health/ready answers 200 or the attempt budget runs out. # Usage: BASE_URL=http://localhost:8080 ATTEMPTS=60 sh student-tests/wait-ready.sh set -eu BASE_URL=${BASE_URL:-http://localhost:8080} ATTEMPTS=${ATTEMPTS:-60} i=0 while [ "$i" -lt "$ATTEMPTS" ]; do if curl -sf "$BASE_URL/health/ready" >/dev/null 2>&1; then echo "ready: $BASE_URL" exit 0 fi i=$((i + 1)) sleep 0.5 done echo "not ready after $ATTEMPTS attempts: $BASE_URL" >&2 exit 1