Files
scadaproj/docs/deploy/2026-11-19-qa-nam-ldap/otopcua-start.ps1
T

28 lines
1.8 KiB
PowerShell

# QA: start OtOpcUaHost on ONE node, wait for /health/ready 200 (up to 180 s), full -Verify, env digest, live version.
$ErrorActionPreference = 'Stop'
function Out-ZbStamped { process { '{0:HH:mm:ss.fff}Z {1}' -f (Get-Date).ToUniversalTime(), "$_" } }
try {
$stageDir = 'E:\psrem-stage\otopcua-cdf433a3'
. "$stageDir\envdigest.ps1"
"node=$env:COMPUTERNAME" | Out-ZbStamped
$t0 = Get-Date
'start issued' | Out-ZbStamped
Start-Service OtOpcUaHost
$deadline = (Get-Date).AddSeconds(180)
$readyCode = 0
while ((Get-Date) -lt $deadline) {
if ((Get-Service OtOpcUaHost).Status -ne 'Running') { Start-Sleep -Milliseconds 500; continue }
try { $readyCode = (Invoke-WebRequest -UseBasicParsing -Uri 'http://localhost:9000/health/ready' -TimeoutSec 5).StatusCode } catch { $readyCode = 0 }
if ($readyCode -eq 200) { break }
Start-Sleep -Milliseconds 500
}
("service={0} ready={1} ({2:N1}s after start issued)" -f (Get-Service OtOpcUaHost).Status, $readyCode, ((Get-Date)-$t0).TotalSeconds) | Out-ZbStamped
Set-Location "$stageDir\install"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\Install-ScriptWorkerIsolation.ps1 -Verify *>&1 | ForEach-Object { "$_" } | Where-Object { $_ -notmatch 'does not inherit the worker deny|grants nothing to Everyone|^\s*(@\{|-DenyPaths\.|to -DenyPaths\.|add it to -DenyPaths\.|RESTRICTED, or add)' } | Where-Object { $_ -match 'VERIFY|MISSING|coverage' }
"post-start verify exit=$LASTEXITCODE" | Out-ZbStamped
Show-ZbEnvDigest @((Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\OtOpcUaHost').Environment) 'post' | Select-Object -First 1
Write-Output ("live ProductVersion=" + (Get-Item 'E:\ApiInstall\OtOpcUa\app\OtOpcUa.Host.dll').VersionInfo.ProductVersion)
if ($readyCode -ne 200) { exit 1 }
exit 0
} catch { Write-Output "START FAILED: $($_.Exception.Message)"; exit 1 }