forked from mtusi2026/mtusi2026lab5
14 lines
527 B
Bash
Executable File
14 lines
527 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
test -n "${TARGET_INSTANCE_ID:-}" || { echo "TARGET_INSTANCE_ID is required" >&2; exit 1; }
|
|
for id in $(./scripts/compose.sh ps -q api); do
|
|
instance="$(docker exec "$id" curl -fsS -D - -o /dev/null http://127.0.0.1:8080/health/live | tr -d '\r' | awk 'tolower($1) == "x-instance-id:" { print $2 }')"
|
|
if [ "$instance" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker stop --time 8 "$id" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
echo "Requested API instance was not found" >&2
|
|
exit 1
|