feat: add HAproxy and 2 api instances

This commit is contained in:
TAskMAster339
2026-10-10 13:20:58 +03:00
parent a856733fe9
commit 771951cad7
23 changed files with 742 additions and 213 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?Set TARGET_INSTANCE_ID to the X-Instance-Id of an API replica}"
for container in $(docker compose --project-name highload-lab3 --env-file .env -f compose.yml ps -q api); do
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
# Only containers from this Compose project's api service are eligible.
docker stop --timeout 8 "$container" >/dev/null
printf 'Stopped API instance %s\n' "$hostname"
exit 0
fi
done
printf 'No running API replica matches TARGET_INSTANCE_ID\n' >&2
exit 1