Files
mtusi2026lab2/scripts/restart.sh
2026-10-16 05:27:13 +03:00

27 lines
843 B
Bash
Executable File

#!/usr/bin/env bash
# Перезапускает api, db и cache, сохраняя volumes (данные и сессии).
# Используется тестом persistence: до рестарта создаём данные,
# после — читаем их тем же токеном.
set -euo pipefail
cd "$(dirname "$0")/.."
echo "stopping services (volumes kept)..." >&2
docker compose --env-file .env stop api db cache
echo "starting services (volumes kept)..." >&2
docker compose --env-file .env up -d
echo "waiting for api readiness..." >&2
for i in $(seq 1 60); do
if curl -fsS http://127.0.0.1:8080/health/ready >/dev/null 2>&1; then
echo "api ready after ${i} attempt(s)" >&2
exit 0
fi
sleep 1
done
echo "api did not become ready in 60s" >&2
docker compose logs api --tail=50 >&2 || true
exit 1