forked from mtusi2026/mtusi2026lab3
Добавить scripts отказа и трека масштабирования
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
compose="docker compose --env-file .env"
|
||||
# Add one ready replica before removing any old container.
|
||||
$compose up -d --scale api=3 --wait --wait-timeout 120 api
|
||||
python3 - <<'PY'
|
||||
import time, urllib.request
|
||||
end=time.monotonic()+60
|
||||
while time.monotonic()<end:
|
||||
try:
|
||||
urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=1).read()
|
||||
break
|
||||
except Exception:
|
||||
time.sleep(.25)
|
||||
else:
|
||||
raise SystemExit('LB did not become ready')
|
||||
PY
|
||||
# Remove one old instance at a time while another healthy backend is present.
|
||||
for id in $(docker compose --env-file .env ps -q api | head -n 2); do
|
||||
docker stop --time 3 "$id" >/dev/null
|
||||
docker rm "$id" >/dev/null
|
||||
docker compose --env-file .env up -d --scale api=3 --wait --wait-timeout 120 api
|
||||
sleep 3
|
||||
done
|
||||
docker compose --env-file .env up -d --scale api=2 --wait --wait-timeout 120 api
|
||||
Reference in New Issue
Block a user