forked from mtusi2026/mtusi2026lab3
Implement Lab 3 grade 4 messenger balancing
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
docker compose start api >/dev/null
|
||||
deadline=$((SECONDS + 60))
|
||||
while (( SECONDS < deadline )); do
|
||||
healthy=0
|
||||
for container_id in $(docker compose ps -q api); do
|
||||
state=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$container_id" 2>/dev/null || true)
|
||||
[[ "$state" == healthy ]] && healthy=$((healthy + 1))
|
||||
done
|
||||
if (( healthy >= 2 )) && curl --fail --silent http://localhost:8080/health/ready >/dev/null; then
|
||||
printf 'PASS: two API replicas are healthy through the load balancer.\n'
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
printf 'API replicas did not recover within 60 seconds.\n' >&2
|
||||
docker compose ps
|
||||
exit 1
|
||||
Reference in New Issue
Block a user