@echo off rem Windows equivalent of restart.sh for local evidence collection. rem Restarts every stateful service and the API replicas without removing volumes. setlocal cd /d "%~dp0.." if not exist ".env" ( echo missing .env; copy .env.example and fill local values 1>&2 exit /b 2 ) set "LAB4_PORT=" for /f "usebackq tokens=1,* delims==" %%a in (".env") do ( if /i "%%a"=="LAB4_PORT" set "LAB4_PORT=%%b" ) if "%LAB4_PORT%"=="" set "LAB4_PORT=8080" docker compose --env-file .env restart postgres seaweedfs haproxy api1 api2 if errorlevel 1 exit /b 1 rem /health/ready covers PostgreSQL and S3, so a 200 means the whole synchronous rem path is usable again. Wait for it before reporting success. rem ping is used instead of timeout: timeout fails when stdin is redirected. for /l %%i in (1,1,90) do ( powershell -NoProfile -Command "try { if ((Invoke-WebRequest -Uri 'http://127.0.0.1:%LAB4_PORT%/health/ready' -UseBasicParsing -TimeoutSec 3).StatusCode -eq 200) { exit 0 } else { exit 1 } } catch { exit 1 }" >nul 2>&1 if not errorlevel 1 exit /b 0 ping -n 2 127.0.0.1 >nul ) echo stack did not become ready within 90 seconds 1>&2 exit /b 1