forked from mtusi2026/mtusi2026lab7
18 lines
514 B
Bash
Executable File
18 lines
514 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
|
|
|
for container in $(docker compose ps -q api); do
|
|
instance=$(docker exec "$container" wget -S -q -O /dev/null http://127.0.0.1:8082/health/live 2>&1 |
|
|
sed -n 's/^[[:space:]]*X-Instance-Id:[[:space:]]*//p' | tr -d '\r')
|
|
if [ "$instance" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker stop --time 6 "$container" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
printf '%s\n' "API instance not found: $TARGET_INSTANCE_ID" >&2
|
|
exit 1
|