|
- <#
- .SYNOPSIS Start the Knowledge Engine containers and wait for PostgreSQL to be healthy.
- #>
- [CmdletBinding()]
- param([switch]$WithOllamaContainer, [int]$TimeoutSeconds = 90)
- $ErrorActionPreference = 'Stop'
- $root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
- $composeArgs = @('compose', '-f', (Join-Path $root 'docker-compose.yml'))
- if ($WithOllamaContainer) { $composeArgs += @('--profile', 'ollama-container') }
- & docker @composeArgs up -d
- if ($LASTEXITCODE -ne 0) { throw 'docker compose up failed.' }
- $deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds)
- do {
- $h = (& docker inspect -f '{{.State.Health.Status}}' foundry-postgres 2>$null)
- if ($h -eq 'healthy') { Write-Host 'foundry-postgres is healthy.'; return }
- Start-Sleep -Seconds 2
- } while ([DateTime]::UtcNow -lt $deadline)
- throw "foundry-postgres did not become healthy within $TimeoutSeconds s (last status: $h)."
|