forked from mtusi2026/mtusi2026lab6
chore: add lab5 files and merge env.example.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
bash "%~dp0restart.sh"
|
||||
exit /b %errorlevel%
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
bash "%~dp0stop-one.sh"
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user