forked from mtusi2026/mtusi2026lab7
13 lines
471 B
Bash
Executable File
13 lines
471 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?Missing tested replica alias}"
|
|
for container in $(docker compose ps -q api); do
|
|
if [[ "$(docker exec "$container" cat /tmp/instance-id)" == "$TARGET_INSTANCE_ID" ]]; then
|
|
docker stop --time 1 "$container" >/dev/null
|
|
printf 'Stopped API alias %s, container %.12s\n' "$TARGET_INSTANCE_ID" "$container" >> evidence/failover-hook.txt
|
|
exit 0
|
|
fi
|
|
done
|
|
exit 1
|