Files
mtusi2026lab4/scripts/stop-one.sh
T

22 lines
483 B
Bash

#!/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