chore(scripts):lab4 add stop-one.sh for failover test
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${TARGET_INSTANCE_ID:?test provides TARGET_INSTANCE_ID (X-Instance-Id header)}"
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
cid=""
|
||||
for c in $(docker compose ps -q api); do
|
||||
host=$(docker inspect -f '{{.Config.Hostname}}' "$c" 2>/dev/null || true)
|
||||
if [ "$host" = "$TARGET_INSTANCE_ID" ]; then
|
||||
cid="$c"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$cid" ]; then
|
||||
echo "no api replica with X-Instance-Id=$TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker stop "$cid" >/dev/null
|
||||
Reference in New Issue
Block a user