9789b01acd
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
34 lines
2.7 KiB
PowerShell
34 lines
2.7 KiB
PowerShell
# QA window on ONE node, started with the service RUNNING (pack §4 QA steps 2/3): Invoke-OtOpcUaInstallSwap.ps1
|
|
# -Carry appsettings*.json,logs -NoStart runs -Scope Outside before its own stop, stops, swaps, -Scope InstallRoot
|
|
# reapply+verify, leaves it STOPPED. Then back up data\ + pki\ (stopped => consistent SQLite triplets). Lines UTC-stamped.
|
|
$ErrorActionPreference = 'Stop'
|
|
function Out-ZbStamped { process { '{0:HH:mm:ss.fff}Z {1}' -f (Get-Date).ToUniversalTime(), "$_" } }
|
|
try {
|
|
$stageDir = 'E:\psrem-stage\otopcua-cdf433a3'
|
|
$backupDir = "$stageDir\backup"
|
|
$candidate = 'E:\ApiInstall\OtOpcUa\app.new-cdf433a3'
|
|
$prevInstall = 'E:\ApiInstall\OtOpcUa\app.bak.20261119-pre-cdf433a3'
|
|
"node=$env:COMPUTERNAME" | Out-ZbStamped
|
|
if (-not (Test-Path -LiteralPath $candidate)) { throw "candidate missing" }
|
|
if (Test-Path -LiteralPath $prevInstall) { throw "prev path already exists: $prevInstall" }
|
|
if ((Get-Service OtOpcUaHost).Status -ne 'Running') { throw "service not running; the pack starts the swap with the service up" }
|
|
'swap invoked (service running)' | Out-ZbStamped
|
|
Set-Location "$stageDir\install"
|
|
& .\Invoke-OtOpcUaInstallSwap.ps1 -InstallRoot E:\ApiInstall\OtOpcUa\app -Candidate $candidate -PreviousInstall $prevInstall `
|
|
-Carry 'appsettings*.json','logs' -NoStart *>&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)' } | Out-ZbStamped
|
|
("swap returned, service={0}" -f (Get-Service OtOpcUaHost).Status) | Out-ZbStamped
|
|
if ((Get-Service OtOpcUaHost).Status -ne 'Stopped') { throw "service not stopped after the -NoStart swap" }
|
|
if (-not (Test-Path -LiteralPath $prevInstall)) { throw "swap did not move the live folder" }
|
|
if (Get-Process -Name 'OtOpcUa.Host' -ErrorAction SilentlyContinue) { throw "OtOpcUa.Host still running" }
|
|
$workerProc = Get-Process -Name 'ZB.MOM.WW.OtOpcUa.ScriptWorker' -ErrorAction SilentlyContinue
|
|
if ($workerProc) { Start-Sleep 3; if (Get-Process -Name 'ZB.MOM.WW.OtOpcUa.ScriptWorker' -ErrorAction SilentlyContinue) { throw "ScriptWorker still running" } }
|
|
foreach ($dirName in 'data','pki') {
|
|
& robocopy.exe "E:\ApiInstall\OtOpcUa\$dirName" "$backupDir\$dirName-pre-cdf433a3" /E /COPY:DAT /R:1 /W:1 /NFL /NDL /NJH /NP | Out-Null
|
|
if ($LASTEXITCODE -ge 8) { throw "$dirName backup robocopy failed $LASTEXITCODE" }
|
|
}
|
|
"data + pki backup ok -> $backupDir" | Out-ZbStamped
|
|
("staged ProductVersion=" + (Get-Item 'E:\ApiInstall\OtOpcUa\app\OtOpcUa.Host.dll').VersionInfo.ProductVersion) | Out-ZbStamped
|
|
exit 0
|
|
} catch { Write-Output "SWAP FAILED: $($_.Exception.Message)"; Write-Output "service=$((Get-Service OtOpcUaHost).Status)"; exit 1 }
|