From c367a970e2dea5f0bed95633a21d0519a0a8bdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Thu, 22 Oct 2026 20:47:12 +0300 Subject: [PATCH] chore(scripts):lab4 add stop-one.sh for failover test --- scripts/stop-one.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/stop-one.sh diff --git a/scripts/stop-one.sh b/scripts/stop-one.sh new file mode 100644 index 0000000..e794359 --- /dev/null +++ b/scripts/stop-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 \ No newline at end of file