forked from mtusi2026/mtusi2026lab4
16 lines
562 B
Bash
Executable File
16 lines
562 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?test provides X-Instance-Id of the target replica}"
|
|
|
|
for container in $(docker compose ps -q api); do
|
|
instance_id=$(docker inspect --format '{{.Config.Hostname}}' "$container")
|
|
if [ "$instance_id" = "$TARGET_INSTANCE_ID" ]; then
|
|
# Manual stop leaves this replica out of service until the operator restores it.
|
|
docker stop --timeout 1 "$container" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
printf '%s\n' 'target API replica was not found; no container was stopped' >&2
|
|
exit 1
|