ЛР4 на 4: MinIO-вложения поверх LB, идемпотентности и failover.

PNG/JPEG через API, student-tests, REPORT и DEFENSE.
This commit is contained in:
2026-12-01 22:01:52 +03:00
parent ec540a1a72
commit 0b4a21a83f
44 changed files with 9152 additions and 37 deletions
Executable
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
# Единая последовательность запуска стенда lab4 (postgres, redis, minio, minio-init, migrate, api×N, lb).
set -eu
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
cd "$ROOT"
COMPOSE="docker compose -p gavrilenko-lab4 --env-file .env"
if [ ! -f .env ]; then
cp .env.example .env
echo "created .env from .env.example" >&2
fi
API_REPLICAS=$(grep -E '^API_REPLICAS=' .env | tail -n1 | cut -d= -f2- || true)
API_REPLICAS=${API_REPLICAS:-2}
LB_PORT=$(grep -E '^LB_HOST_PORT=' .env | tail -n1 | cut -d= -f2- || true)
LB_PORT=${LB_PORT:-8081}
$COMPOSE config --quiet
$COMPOSE up -d --build --wait postgres redis minio
$COMPOSE run --rm minio-init
$COMPOSE run --rm --build migrate
$COMPOSE up -d --build --scale "api=${API_REPLICAS}" --no-deps api
$COMPOSE up -d --no-deps lb
echo "waiting for http://127.0.0.1:${LB_PORT}/health/ready via LB..."
deadline=$(( $(date +%s) + 120 ))
while :; do
if curl -fsS "http://127.0.0.1:${LB_PORT}/health/ready" >/dev/null 2>&1; then
echo "ready"
$COMPOSE ps
exit 0
fi
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "timeout waiting for readiness" >&2
$COMPOSE ps >&2 || true
$COMPOSE logs --tail=80 api lb minio >&2 || true
exit 1
fi
sleep 1
done