Перенесите реализацию ЛР 4 на стенд ЛР 5
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Failover hook of `make test-failover`: gracefully stops the one running API
|
||||
# replica whose X-Instance-Id is $TARGET_INSTANCE_ID, and nothing else.
|
||||
# Restore it with: docker compose start api
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
target=${TARGET_INSTANCE_ID:-}
|
||||
case "$target" in
|
||||
'' | *[!0-9a-f]*)
|
||||
echo "TARGET_INSTANCE_ID must be the 16 lowercase hex characters of an X-Instance-Id" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
if [ ${#target} -ne 16 ]; then
|
||||
echo "TARGET_INSTANCE_ID must be the 16 lowercase hex characters of an X-Instance-Id" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
matches=$(sh scripts/api-instances.sh | awk -v t="$target" '$3 == "running" && $4 == t { print $1 }')
|
||||
count=$(printf '%s\n' "$matches" | grep -c . || true)
|
||||
if [ "$count" -ne 1 ]; then
|
||||
echo "expected one running API replica with X-Instance-Id $target, found $count" >&2
|
||||
exit 2
|
||||
fi
|
||||
docker stop "$matches" >/dev/null
|
||||
echo "stopped API container $matches (X-Instance-Id $target)"
|
||||
Reference in New Issue
Block a user