forked from mtusi2026/mtusi2026lab2
36 lines
1.2 KiB
Batchfile
36 lines
1.2 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
cd /d "%~dp0.."
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Stopping API...
|
|
docker compose --env-file .env stop api
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Stopping Redis...
|
|
docker compose --env-file .env stop redis
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Stopping PostgreSQL...
|
|
docker compose --env-file .env stop postgres
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Starting storage services and waiting for healthchecks...
|
|
docker compose --env-file .env up -d --no-deps --wait --wait-timeout 45 postgres redis
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Starting API...
|
|
docker compose --env-file .env up -d --no-deps api
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] Waiting for API readiness (PostgreSQL + Redis)...
|
|
powershell.exe -NoProfile -NonInteractive -Command "$deadline=(Get-Date).AddSeconds(30); while((Get-Date) -lt $deadline) { try { $r=Invoke-WebRequest -UseBasicParsing -Uri 'http://127.0.0.1:8080/health/ready' -TimeoutSec 2 -ErrorAction Stop; if($r.StatusCode -eq 200) { exit 0 } } catch {} ; Start-Sleep -Seconds 1 }; exit 1"
|
|
if errorlevel 1 goto :fail
|
|
|
|
echo [restart] OK: all runtime services restarted; API ready.
|
|
exit /b 0
|
|
|
|
:fail
|
|
echo [restart] FAILED. Inspect docker compose ps and logs. 1>&2
|
|
exit /b 1
|