chore(scripts):lab4 add stop-one.sh for failover test

This commit is contained in:
Голиков Maximillian Антон
2026-10-22 20:47:12 +03:00
parent e9213a533e
commit c367a970e2
+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