#!/bin/sh # Stop exactly one API replica identified by the X-Instance-Id alias supplied # by the failover test. The replica is intentionally left stopped; restore it # explicitly with: docker compose start api1 (or api2). set -eu : "${TARGET_INSTANCE_ID:?test provides target API instance alias}" case "$TARGET_INSTANCE_ID" in api-1) service=api1 ;; api-2) service=api2 ;; *) printf 'unknown API instance alias: %s\n' "$TARGET_INSTANCE_ID" >&2 exit 2 ;; esac ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) cd "$ROOT" # -t 2 keeps the hook well inside the test's 10 second budget. `stop` keeps the # container (and volumes) in place and the container is not restarted by policy. exec docker compose --env-file .env -f compose.yaml stop --timeout 2 "$service"