#!/bin/sh set -eu : "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}" cd "$(dirname "$0")/.." found="" for cid in $(docker compose --env-file .env -f compose.yaml ps -q api); do host=$(docker inspect -f '{{.Config.Hostname}}' "$cid") short=$(printf '%s' "$cid" | cut -c1-12) if [ "$host" = "$TARGET_INSTANCE_ID" ] || [ "$short" = "$TARGET_INSTANCE_ID" ]; then found=$cid break fi done if [ -z "$found" ]; then echo "API replica was not found" >&2 exit 1 fi # docker stop оставляет реплику выключенной: restart policy unless-stopped. docker stop -t 8 "$found" >/dev/null