Files
mtusi2026lab4/scripts/up.sh
T
Mlvn 7cbb75c897 Реализовать lab4: вложения S3/MinIO, уровень 4 и трек 2 reconciler.
Метаданные в PostgreSQL, байты в приватном bucket; sync upload 201 ready;
компенсация orphan и cmd/reconcile с dry-run/apply и grace period.
2026-11-12 18:08:47 +03:00

39 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# Единая последовательность запуска стенда lab4.
# 1) postgres+redis+minio 2) bootstrap bucket 3) миграции 4) API×N 5) HAProxy
set -eu
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
cd "$ROOT"
if [ ! -f .env ]; then
cp .env.example .env
echo "created .env from .env.example" >&2
fi
API_REPLICAS=$(grep -E '^API_REPLICAS=' .env | cut -d= -f2- || true)
API_REPLICAS=${API_REPLICAS:-2}
docker compose --env-file .env config --quiet
docker compose --env-file .env up -d --build postgres redis minio
docker compose --env-file .env run --rm minio-init
docker compose --env-file .env run --rm --build migrate
docker compose --env-file .env up -d --build --scale "api=${API_REPLICAS}" --no-deps api
docker compose --env-file .env up -d --no-deps lb
echo "waiting for http://127.0.0.1:8080/health/ready via LB..."
deadline=$(( $(date +%s) + 180 ))
while :; do
if curl -fsS "http://127.0.0.1:8080/health/ready" >/dev/null 2>&1; then
echo "ready"
docker compose --env-file .env ps
exit 0
fi
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "timeout waiting for readiness" >&2
docker compose --env-file .env ps >&2 || true
docker compose --env-file .env logs --tail=80 api lb minio minio-init >&2 || true
exit 1
fi
sleep 1
done