#!/bin/sh set -eu ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) cd "$ROOT" : "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}" for container in $(docker compose ps -q api); do hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container") if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then docker stop --time 2 "$container" >/dev/null exit 0 fi done printf '%s\n' 'No running API replica matches TARGET_INSTANCE_ID' >&2 exit 1