forked from mtusi2026/mtusi2026lab3
feat(infra): add replicated API and readiness-aware load balancing
Provide resource profiles, persistent storage, parallel Nginx health checks and graceful restart hooks.
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$project_dir"
|
||||
|
||||
target=${TARGET_INSTANCE_ID:?test provides target API instance ID}
|
||||
|
||||
containers=$(docker compose ps --all --quiet api)
|
||||
if [ -z "$containers" ]; then
|
||||
printf 'No API containers found\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
for entry in $(docker inspect --format '{{.Config.Hostname}}:{{.Id}}' $containers); do
|
||||
instance=${entry%%:*}
|
||||
container=${entry#*:}
|
||||
if [ "$instance" = "$target" ]; then
|
||||
docker stop --time 30 "$container" >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
printf 'No API container matches X-Instance-Id\n' >&2
|
||||
exit 2
|
||||
Reference in New Issue
Block a user