Собрать стенд lab3: балансировка, идемпотентность и трек 1

This commit is contained in:
Wladislava1
2026-11-06 16:04:28 +03:00
parent 0ab3a341aa
commit d9e13a06d9
42 changed files with 3602 additions and 33 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
set -eu
# Поочерёдный рестарт API-реплик. Следующую не трогаем, пока текущая снова healthy.
ids=$(docker ps -q \
--filter label=com.docker.compose.project=mtusi-lab3 \
--filter label=com.docker.compose.service=api)
if [ -z "$ids" ]; then
echo "no api replicas" >&2
exit 1
fi
for id in $ids; do
docker restart --time 5 "$id" >/dev/null
i=0
while [ "$i" -lt 40 ]; do
status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$id")
if [ "$status" = "healthy" ]; then
break
fi
i=$((i + 1))
sleep 1
done
if [ "$i" -ge 40 ]; then
echo "replica did not become healthy" >&2
exit 1
fi
# rise 2 у HAProxy: дать балансировщику вернуть реплику в ротацию.
sleep 2
done