Files
mtusi2026lab5/scripts/wait-ready.sh
T

23 lines
635 B
Bash

#!/bin/sh
# Compose may retain the balancer's earlier healthy status while API backends
# are recreated. Wait for fresh successful responses through the real LB.
set -eu
cd "$(dirname "$0")/.."
attempt=0
stable=0
while [ "$attempt" -lt 60 ]; do
if docker compose exec -T lb wget -qO- http://127.0.0.1:8080/health/ready >/dev/null 2>&1; then
stable=$((stable + 1))
if [ "$stable" -ge 3 ]; then
echo "balancer readiness confirmed"
exit 0
fi
else
stable=0
fi
attempt=$((attempt + 1))
sleep 1
done
echo "balancer did not become ready within 60 probes" >&2
exit 1