forked from mtusi2026/mtusi2026lab2
Implement lab2 PostgreSQL authentication and Redis sessions
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
@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
|
||||
Reference in New Issue
Block a user