Complete lab 2 PostgreSQL Redis implementation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
Push-Location $ProjectRoot
|
||||
try {
|
||||
Write-Host "Restarting API, PostgreSQL and Redis without removing volumes..."
|
||||
docker compose restart api postgres redis
|
||||
if ($LASTEXITCODE -ne 0) { throw "docker compose restart failed" }
|
||||
|
||||
$deadline = (Get-Date).AddSeconds(90)
|
||||
do {
|
||||
Start-Sleep -Seconds 2
|
||||
$ready = $false
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "http://127.0.0.1:8080/health/ready" -TimeoutSec 3
|
||||
$ready = ($response.status -eq "ok")
|
||||
} catch { }
|
||||
if ($ready) {
|
||||
$states = docker compose ps --format json | ConvertFrom-Json
|
||||
$healthy = @($states | Where-Object { $_.Health -eq "healthy" })
|
||||
if ($healthy.Count -ge 3) {
|
||||
Write-Host "PASS: API and both stores are healthy. Named volumes were preserved."
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
} while ((Get-Date) -lt $deadline)
|
||||
throw "Stack did not become healthy within 90 seconds"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user