all for 3

This commit is contained in:
2026-11-22 20:57:19 +03:00
parent 20afc2c790
commit 883b3e0305
161 changed files with 12479 additions and 36 deletions
+46
View File
@@ -0,0 +1,46 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?Не задан TARGET_INSTANCE_ID}"
compose() {
docker compose --env-file .env -f compose.yml "$@"
}
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 stop -t 0 "$target" >/dev/null
printf '%s\n' "Остановлена API-реплика: $TARGET_INSTANCE_ID"