Complete Lab 5 grade 4 async attachment pipeline
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
docker compose --env-file .env up -d dispatcher worker >/dev/null
|
||||
docker compose --env-file .env up -d --scale api=2 api lb >/dev/null
|
||||
deadline=$((SECONDS + 60))
|
||||
while (( SECONDS < deadline )); do
|
||||
healthy=0
|
||||
for container_id in $(docker compose --env-file .env 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 )) && docker compose --env-file .env exec -T lb wget -q -O /dev/null http://127.0.0.1:8080/health/ready; 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 --env-file .env ps
|
||||
exit 1
|
||||
Reference in New Issue
Block a user