Добавить балансировку и идемпотентность для лабораторной 3.

Две реплики API за HAProxy, общий PostgreSQL и повтор сообщения без дубля.
This commit is contained in:
2026-11-13 07:30:46 +00:00
parent 0ab3a341aa
commit e0e1a1e6c1
21 changed files with 1997 additions and 14 deletions
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
docker compose --env-file .env restart postgres api lb
+15
View File
@@ -0,0 +1,15 @@
#!/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