forked from mtusi2026/mtusi2026lab3
15 lines
726 B
PowerShell
15 lines
726 B
PowerShell
# Windows PowerShell version of scripts/start-replicas.sh: start stopped API replicas, wait for healthy.
|
|
$ErrorActionPreference = 'Continue'
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
Set-Location $root
|
|
$envFile = if ($env:ENV_FILE) { $env:ENV_FILE } else { '.env' }
|
|
$ids = @(& docker compose --env-file $envFile ps -a -q api)
|
|
foreach ($cid in $ids) { & docker start $cid | Out-Null }
|
|
for ($i = 0; $i -lt 120; $i++) {
|
|
$bad = @($ids | Where-Object { (& docker inspect -f '{{.State.Health.Status}}' $_) -ne 'healthy' }).Count
|
|
if ($bad -eq 0) { break }
|
|
Start-Sleep -Milliseconds 500
|
|
}
|
|
foreach ($cid in $ids) { & docker inspect -f '{{.Name}} {{.State.Status}} {{.State.Health.Status}}' $cid }
|
|
if ($bad -ne 0) { exit 1 }
|