forked from mtusi2026/mtusi2026lab3
14 lines
414 B
Bash
Executable File
14 lines
414 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?Required API hostname from X-Instance-Id}"
|
|
for id in $(scripts/compose.sh ps -q api); do
|
|
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$id")
|
|
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker stop --time 3 "$id" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
printf '%s\n' 'Target is not a running API replica' >&2
|
|
exit 1
|