50a5291b64
DEV: ~48 s site / ~29 s central outage; QA: pair stop/start, ~2m40s site / ~1m37s central. Chain schema + chainer role gone, env key removed, all gates pass on both tiers. #116 QA site drills (all reactors idle): kill → takeover +7.7 s; stop-and-hold → [leader-auto-down] DOWNING +27.2 s, takeover +27.4 s, recovery restored byte-identical. Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
28 lines
2.0 KiB
PowerShell
28 lines
2.0 KiB
PowerShell
# #116 QA site-pair drill helper. Rendered per call: ACTION. Service ScadaBridge-Site only.
|
|
$ErrorActionPreference = 'Stop'
|
|
$Action = '__ACTION__'
|
|
$svc = 'ScadaBridge-Site'
|
|
function Say($m) { "[{0:HH:mm:ss.fff}] {1} {2}" -f (Get-Date), $env:COMPUTERNAME, $m }
|
|
function Rec { Say ("qfailure: " + ((& sc.exe qfailure $svc | Out-String) -replace '\s+',' ').Trim()); Say ("qfailureflag: " + ((& sc.exe qfailureflag $svc | Out-String) -replace '\s+',' ').Trim()) }
|
|
$pidNow = (Get-CimInstance Win32_Service -Filter "Name='$svc'").ProcessId
|
|
switch ($Action) {
|
|
'status' { Say "$svc state $((Get-Service $svc).Status) pid $pidNow"; Rec }
|
|
'kill' {
|
|
if (-not $pidNow -or $pidNow -eq 0) { throw "no running pid for $svc" }
|
|
$p = Get-Process -Id $pidNow; if ($p.ProcessName -ne 'ZB.MOM.WW.ScadaBridge.Host') { throw "pid $pidNow is $($p.ProcessName)" }
|
|
Say "KILL $svc pid $pidNow"; Stop-Process -Id $pidNow -Force; Say "killed" }
|
|
'disable' {
|
|
& sc.exe failure $svc reset= 86400 actions= none/0/none/0/none/0 | Out-Null; if ($LASTEXITCODE -ne 0) { throw "sc failure disable" }
|
|
$q = (& sc.exe qfailure $svc | Out-String); if ($q -match 'RESTART') { throw "restart action still present" }; Rec }
|
|
'kill-held' {
|
|
$q = (& sc.exe qfailure $svc | Out-String); if ($q -match 'RESTART') { throw "refusing: restart action present" }
|
|
$p = Get-Process -Id $pidNow; if ($p.ProcessName -ne 'ZB.MOM.WW.ScadaBridge.Host') { throw "pid $pidNow is $($p.ProcessName)" }
|
|
Say "KILL-HELD $svc pid $pidNow"; Stop-Process -Id $pidNow -Force; Say "killed (no auto-restart)" }
|
|
'restore' {
|
|
& sc.exe failure $svc reset= 86400 actions= restart/5000/restart/5000/restart/10000 | Out-Null; if ($LASTEXITCODE -ne 0) { throw "sc failure restore" }
|
|
& sc.exe failureflag $svc 1 | Out-Null; Rec }
|
|
'start' { Say "starting $svc"; Start-Service $svc; (Get-Service $svc).WaitForStatus('Running','00:01:00'); Say "running pid $((Get-CimInstance Win32_Service -Filter "Name='$svc'").ProcessId)" }
|
|
default { throw "bad action" }
|
|
}
|
|
exit 0
|