chore: add lab5 files and merge env.example.

This commit is contained in:
Голиков Maximillian Антон
2026-11-14 16:12:32 +03:00
parent 470d9d6f1e
commit 0d1a4261f8
93 changed files with 7085 additions and 11 deletions
+3
View File
@@ -0,0 +1,3 @@
@echo off
bash "%~dp0restart.sh"
exit /b %errorlevel%
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
# Перезапускаем state stores, API и Worker
docker compose restart postgres redis minio rabbitmq api worker
i=0
while [ "$i" -lt 90 ]; do
# Проверяем статус всех нужных сервисов
unhealthy=$(docker compose ps --format '{{.Service}} {{.Health}}' \
| awk '$1 ~ /^(postgres|redis|minio|rabbitmq|api-[0-9]+)$/ && $2 != "healthy" {print $1}')
if [ -z "$unhealthy" ]; then
# Даем базе и пулам соединений 5 секунд стабилизироваться
sleep 5
exit 0
fi
i=$((i+1))
sleep 1
done
echo "основные сервисы не прошли проверку здоровья за 90 секунд: $unhealthy" >&2
docker compose ps >&2
exit 1
+2
View File
@@ -0,0 +1,2 @@
@echo off
bash "%~dp0stop-one.sh"
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides TARGET_INSTANCE_ID (X-Instance-Id header)}"
cd "$(dirname "$0")/.."
cid=""
for c in $(docker compose ps -q api); do
host=$(docker inspect -f '{{.Config.Hostname}}' "$c" 2>/dev/null || true)
if [ "$host" = "$TARGET_INSTANCE_ID" ]; then
cid="$c"
break
fi
done
if [ -z "$cid" ]; then
echo "no api replica with X-Instance-Id=$TARGET_INSTANCE_ID" >&2
exit 1
fi
docker stop "$cid" >/dev/null