|
|
@@ -211,20 +211,31 @@ if (-not $GuiOnly) {
|
|
|
@{ Name = "Seq-Interp"; Url = "http://localhost:$(Get-EnvPort 'SEQ_INTERP_PORT' '7475')/health"; Required = $true },
|
|
|
@{ Name = "Reconstructor"; Url = "http://localhost:$(Get-EnvPort 'RECONSTRUCTOR_PORT' '8081')/health"; Required = $true },
|
|
|
@{ Name = "Spectroscopy"; Url = "http://localhost:$(Get-EnvPort 'SPECTROSCOPY_PORT' '8002')/health"; Required = $true },
|
|
|
- @{ Name = "Spectrometer"; Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT' '8000')/api/"; Required = $checkSpec }
|
|
|
+ @{ Name = "Spectrometer"; Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT' '8000')/api/"; Required = $checkSpec; AllowedCodes = @(200,301,302,401,403) }
|
|
|
)
|
|
|
|
|
|
$maxWait = 120; $interval = 3; $elapsed = 0
|
|
|
+ # Helper: returns $true if the TCP port is accepting connections.
|
|
|
+ # Using TCP instead of HTTP so HTTP 4xx / auth errors don't cause false negatives.
|
|
|
+ function Test-ServiceUp($svc) {
|
|
|
+ try {
|
|
|
+ $uri = [System.Uri]$svc.Url
|
|
|
+ $port = if ($uri.Port -gt 0) { $uri.Port } else { 80 }
|
|
|
+ $tcp = New-Object System.Net.Sockets.TcpClient
|
|
|
+ $ar = $tcp.BeginConnect($uri.Host, $port, $null, $null)
|
|
|
+ $ok = $ar.AsyncWaitHandle.WaitOne(1500, $false)
|
|
|
+ try { $tcp.Close() } catch {}
|
|
|
+ return $ok
|
|
|
+ } catch {
|
|
|
+ return $false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
while ($elapsed -lt $maxWait) {
|
|
|
$pending = @()
|
|
|
foreach ($svc in $services) {
|
|
|
if (-not $svc.Required) { continue }
|
|
|
- $up = $false
|
|
|
- try {
|
|
|
- $r = Invoke-WebRequest $svc.Url -UseBasicParsing -TimeoutSec 2 -ErrorAction Stop
|
|
|
- $up = ($r.StatusCode -lt 400)
|
|
|
- } catch {}
|
|
|
- if (-not $up) { $pending += $svc.Name }
|
|
|
+ if (-not (Test-ServiceUp $svc)) { $pending += $svc.Name }
|
|
|
}
|
|
|
if ($pending.Count -eq 0) { Write-OK "All required services healthy"; break }
|
|
|
Write-Host (" ... {0}/{1} s waiting: {2}" -f $elapsed, $maxWait, ($pending -join ", ")) -ForegroundColor DarkGray
|
|
|
@@ -235,18 +246,10 @@ if (-not $GuiOnly) {
|
|
|
|
|
|
Write-Host ""
|
|
|
foreach ($svc in $services) {
|
|
|
- $ok = $false
|
|
|
- try {
|
|
|
- $r = Invoke-WebRequest $svc.Url -UseBasicParsing -TimeoutSec 2 -ErrorAction Stop
|
|
|
- $ok = ($r.StatusCode -lt 400)
|
|
|
- } catch {}
|
|
|
+ $ok = Test-ServiceUp $svc
|
|
|
$icon = if ($ok) { "[OK]" } else { "[--]" }
|
|
|
$color = if ($ok) { "Green" } elseif ($svc.Required) { "Yellow" } else { "DarkGray" }
|
|
|
- if (-not $svc.Required -and -not $ok) {
|
|
|
- $suffix = " (native -- start manually)"
|
|
|
- } else {
|
|
|
- $suffix = ""
|
|
|
- }
|
|
|
+ $suffix = if (-not $svc.Required -and -not $ok) { " (native -- start manually)" } else { "" }
|
|
|
Write-Host (" {0,-6} {1,-16} {2}{3}" -f $icon, $svc.Name, $svc.Url, $suffix) -ForegroundColor $color
|
|
|
}
|
|
|
|