This commit is contained in:
2026-10-26 21:32:36 +03:00
parent 0ab3a341aa
commit 551139d628
125 changed files with 1516665 additions and 22 deletions
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
docker compose stop -t 20 api lb
docker compose restart postgres redis
docker compose up -d --no-deps --no-recreate \
--wait --wait-timeout 30 postgres redis
docker compose start api lb
+48
View File
@@ -0,0 +1,48 @@
#!/bin/sh
set -eu
# Переходим в корень проекта.
cd "$(dirname "$0")/.."
# Переменную передаёт тест failover.
: "${TARGET_INSTANCE_ID:?Не задан TARGET_INSTANCE_ID}"
compose() {
docker compose --env-file .env -f compose.yaml "$@"
}
containers=$(compose ps --status running -q api)
target=""
count=0
for container in $containers; do
count=$((count + 1))
instance_id=$(docker inspect \
--format '{{.Config.Hostname}}' "$container")
if [ "$instance_id" = "$TARGET_INSTANCE_ID" ]; then
if [ -n "$target" ]; then
printf '%s\n' 'Ошибка: найдено несколько подходящих реплик.' >&2
exit 1
fi
target="$container"
fi
done
if [ "$count" -lt 2 ]; then
printf '%s\n' 'Ошибка: должны работать минимум две API-реплики.' >&2
exit 1
fi
if [ -z "$target" ]; then
printf '%s\n' 'Ошибка: указанная API-реплика не найдена.' >&2
exit 1
fi
docker kill --signal=KILL "$target" >/dev/null
printf '%s\n' "Остановлена API-реплика: $TARGET_INSTANCE_ID"