create skeleton for lab 3

This commit is contained in:
2026-10-30 00:53:49 +03:00
parent 0ab3a341aa
commit df49fb5df4
86 changed files with 5284 additions and 10 deletions
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
# Перезапуск API и всех хранилищ с сохранением volumes (make test-persistence).
# У api несколько реплик, перед ними nginx.
set -eu
cd "$(dirname "$0")/.."
compose() {
docker compose --env-file .env "$@"
}
# Ждёт, пока ВСЕ контейнеры service станут healthy (у api их несколько).
wait_healthy() {
for service in "$@"; do
attempts=0
until states=$(compose ps --format '{{.Health}}' "$service") \
&& [ -n "$states" ] \
&& [ -z "$(printf '%s\n' "$states" | grep -v '^healthy$')" ]; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 60 ]; then
echo "$service не стал healthy за 60 секунд" >&2
exit 1
fi
sleep 1
done
done
}
compose restart postgres redis
wait_healthy postgres redis
compose restart api
wait_healthy api
# TODO(3.3): если nginx перерезолвит DNS сам, рестарт LB не обязателен —
# но перезапуск «всего стенда» в защите всё равно его включает.
compose restart nginx
wait_healthy nginx