fix(#72): wait for API and retry SYB load

This commit is contained in:
QiuSW
2026-08-24 11:02:47 +08:00
parent ca0c81b9f0
commit 476ca64616
7 changed files with 96 additions and 17 deletions
+28
View File
@@ -77,6 +77,32 @@ function Read-PortConfig {
return @{ Server = [int]$values.server; Web = [int]$values.web }
}
function Wait-ApiReady {
param(
[int]$Port,
[int]$TimeoutSeconds = 60
)
$healthUrl = "http://127.0.0.1:${Port}/api/v1/health"
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
Write-Host "Waiting for GoAuto API at $healthUrl ..." -ForegroundColor Cyan
while ($stopwatch.Elapsed.TotalSeconds -lt $TimeoutSeconds) {
try {
$response = Invoke-WebRequest -Uri $healthUrl -UseBasicParsing -TimeoutSec 2
if ($response.StatusCode -eq 200) {
Write-Host "GoAuto API is ready." -ForegroundColor Green
return
}
}
catch {
# The API process may still be migrating or compiling.
}
Start-Sleep -Milliseconds 1000
}
throw "GoAuto API did not become ready within ${TimeoutSeconds}s: $healthUrl"
}
if ([string]::IsNullOrWhiteSpace($ConfigPath)) {
$ConfigPath = Join-Path $workspaceRoot "config.yaml"
}
@@ -94,6 +120,8 @@ if ($ValidateConfigOnly) {
return
}
Wait-ApiReady -Port $ports.Server
$node = Get-Command node.exe -ErrorAction SilentlyContinue
if ($node) {
$nodePath = $node.Source