forked from mtusi2026/mtusi2026lab3
16 lines
479 B
Bash
Executable File
16 lines
479 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?}"
|
|
found=0
|
|
for id in $(docker compose --env-file .env ps -q api); do
|
|
docker exec "$id" curl -fsS -o /dev/null -D /tmp/live-headers.txt http://127.0.0.1:8080/health/live || true
|
|
got=$(docker exec "$id" grep -i "^x-instance-id:" /tmp/live-headers.txt | awk "{print \$2}" | tr -d "\r")
|
|
if [ "$got" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker stop -t 5 "$id"
|
|
found=1
|
|
break
|
|
fi
|
|
done
|
|
test "$found" -eq 1
|