forked from mtusi2026/mtusi2026lab3
lab3
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
compose() {
|
||||
docker compose --env-file .env "$@"
|
||||
}
|
||||
|
||||
deadline=$(( $(date +%s) + 70 ))
|
||||
|
||||
wait_healthy() {
|
||||
svc=$1
|
||||
want=1
|
||||
if [ "$svc" = "api" ]; then
|
||||
want=${API_REPLICAS:-2}
|
||||
fi
|
||||
while [ "$(date +%s)" -lt "$deadline" ]; do
|
||||
states=$(compose ps "$svc" --format '{{.Health}}' || true)
|
||||
n=$(printf '%s\n' "$states" | grep -cx healthy || true)
|
||||
if [ "$n" -ge "$want" ]; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "timed out waiting for $svc" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
compose restart db cache
|
||||
wait_healthy db
|
||||
wait_healthy cache
|
||||
compose start api
|
||||
compose restart api
|
||||
wait_healthy api
|
||||
compose restart lb
|
||||
wait_healthy lb
|
||||
exit 0
|
||||
Reference in New Issue
Block a user