forked from mtusi2026/mtusi2026lab3
grade4
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
wait_ready() {
|
||||
svc=$1
|
||||
timeout=60
|
||||
echo "Waiting for $svc readiness (up to ${timeout}s)..."
|
||||
while [ "$timeout" -gt 0 ]; do
|
||||
if docker compose exec -T "$svc" python -c \
|
||||
"import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')" 2>/dev/null; then
|
||||
echo "$svc is ready!"
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
timeout=$((timeout - 1))
|
||||
done
|
||||
echo "$svc failed to become ready" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "Starting Rolling Update"
|
||||
|
||||
echo "1. Rebuilding and replacing api-1..."
|
||||
docker compose up -d --no-deps --build --force-recreate api-1
|
||||
wait_ready api-1
|
||||
echo "Reloading nginx to pick up new api-1 IP..."
|
||||
docker compose exec -T nginx nginx -s reload
|
||||
|
||||
echo "2. Rebuilding and replacing api-2..."
|
||||
docker compose up -d --no-deps --build --force-recreate api-2
|
||||
wait_ready api-2
|
||||
echo "Reloading nginx to pick up new api-2 IP..."
|
||||
docker compose exec -T nginx nginx -s reload
|
||||
|
||||
echo "Rolling Update Completed Successfully"
|
||||
Reference in New Issue
Block a user