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