forked from mtusi2026/mtusi2026lab4
lab3
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
docker compose restart
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
docker compose restart
|
||||
@@ -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"
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
||||
|
||||
if [ "$TARGET_INSTANCE_ID" = "api-replica-1" ]; then
|
||||
docker compose stop -t 3 api-1
|
||||
elif [ "$TARGET_INSTANCE_ID" = "api-replica-2" ]; then
|
||||
docker compose stop -t 3 api-2
|
||||
else
|
||||
echo "Unknown target instance: $TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user