Поставить несколько реплик API за общий балансировщик.

Сессия и ключ идемпотентности общие для реплик, миграция выполняется один раз, остановка одной реплики не теряет подтверждённые сообщения.
This commit is contained in:
2026-10-30 01:15:28 +03:00
parent 0ab3a341aa
commit 59f8c55f93
45 changed files with 3367 additions and 36 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
# Stop the API replica named by TARGET_INSTANCE_ID and leave it stopped.
# Does not stop the database, Redis, the load balancer, or any volume.
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
cd "$ROOT"
found=""
for cid in $(docker compose --env-file .env ps -q api); do
host=$(docker inspect -f '{{.Config.Hostname}}' "$cid")
short=$(docker inspect -f '{{.Id}}' "$cid" | cut -c1-12)
name=$(docker inspect -f '{{.Name}}' "$cid" | sed 's#^/##')
if [ "$host" = "$TARGET_INSTANCE_ID" ] || [ "$short" = "$TARGET_INSTANCE_ID" ] || [ "$name" = "$TARGET_INSTANCE_ID" ]; then
found=$cid
break
fi
done
if [ -z "$found" ]; then
echo "no running api container matches the instance" >&2
exit 1
fi
docker stop -t 6 "$found" >/dev/null