forked from mtusi2026/mtusi2026lab6
19 lines
492 B
Bash
Executable File
19 lines
492 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
|
cd "$(dirname "$0")/.."
|
|
|
|
for service in api-a api-b; do
|
|
container="$(docker compose ps -q "$service")"
|
|
[ -n "$container" ] || continue
|
|
hostname="$(docker inspect --format '{{.Config.Hostname}}' "$container")"
|
|
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker compose stop "$service"
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
printf '%s\n' 'TARGET_INSTANCE_ID does not match a running API replica' >&2
|
|
exit 2
|