mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 08:10:47 +08:00
fix(startup): defer alarm pull 60s; health probe accepts only HTTP 200
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f562f50953
commit
65e0713e94
3 changed files with 30 additions and 3 deletions
|
|
@ -95,10 +95,17 @@ function Show-LogTail {
|
|||
function Test-NetxApiListening {
|
||||
param([string]$HostName, [int]$LocalPort, [int]$WaitSec = 45)
|
||||
$deadline = (Get-Date).AddSeconds($WaitSec)
|
||||
$healthUrl = "http://${HostName}:${LocalPort}/health"
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
try {
|
||||
$r = Invoke-WebRequest -Uri "http://${HostName}:${LocalPort}/health" -UseBasicParsing -TimeoutSec 2
|
||||
if ($r.StatusCode -eq 200) { return $true }
|
||||
# Only HTTP 200 with {"status":"ok"} counts; no redirects / other codes.
|
||||
$r = Invoke-WebRequest -Uri $healthUrl -UseBasicParsing -TimeoutSec 2 -MaximumRedirection 0
|
||||
if ($r.StatusCode -ne 200) {
|
||||
Start-Sleep -Milliseconds 500
|
||||
continue
|
||||
}
|
||||
$body = $r.Content | ConvertFrom-Json -ErrorAction Stop
|
||||
if ($body.status -eq "ok") { return $true }
|
||||
} catch {}
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue