#!/bin/sh # Map the public random alias to the compose service and stop only that replica. set -eu cd "$(dirname "$0")/.." : "${TARGET_INSTANCE_ID:?test provides target API instance alias}" found="" for dir in run/instances/*; do [ -f "$dir/id" ] || continue current=$(tr -d '\r\n' < "$dir/id") if [ "$current" = "$TARGET_INSTANCE_ID" ]; then found=$(basename "$dir") break fi done if [ -z "$found" ]; then echo "unknown instance alias" >&2 exit 1 fi case "$found" in api-1|api-2) ;; *) echo "alias does not belong to an API replica" >&2; exit 1 ;; esac docker compose --env-file .env stop -t 2 "$found"