#!/bin/sh set -eu # Stop exactly ONE API replica and leave it stopped. # # TARGET_INSTANCE_ID is the X-Instance-Id observed by the test, which equals the # replica's container hostname (Docker's short container id). We map it to the # running api container and stop it with a short grace period so the hook # returns well within the 10 second budget. PostgreSQL, Valkey and the balancer # are never touched. : "${TARGET_INSTANCE_ID:?test provides target API instance alias}" cd "$(dirname "$0")/.." target="" for id in $(docker ps --filter "label=com.docker.compose.service=api" --format '{{.ID}}'); do case "$id" in "$TARGET_INSTANCE_ID"*) target="$id" ;; esac done if [ -z "$target" ]; then echo "no running API replica matches X-Instance-Id=$TARGET_INSTANCE_ID" >&2 exit 1 fi docker stop -t 5 "$target" >/dev/null exit 0