Implement Lab 3 grade 4 messenger balancing

This commit is contained in:
2026-11-12 20:48:24 +03:00
parent 0ab3a341aa
commit db070826c0
52 changed files with 1967 additions and 50 deletions
+20
View File
@@ -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