feat(install): rewrite Install/Refresh/Uninstall-Services.ps1 for v2 fused Host (Task 62)
- Install-Services.ps1: installs OtOpcUaHost (single fused binary) replacing the v1 OtOpcUa + OtOpcUaAdmin pair. Required -Roles param writes OTOPCUA_ROLES to the service env so Program.cs decides what to mount (admin / driver / both). -HttpPort param (default 9000) writes ASPNETCORE_URLS on admin-role nodes. sc.exe restart-on-failure: 5s, 30s, 60s; reset counter after 24h clean run. Wonderware historian sidecar install logic preserved from v1. - Uninstall-Services.ps1: removes OtOpcUaHost + cleans up legacy v1 names (OtOpcUa, OtOpcUaAdmin) and the long-retired OtOpcUaGalaxyHost. - Refresh-Services.ps1: updated service names (OtOpcUa -> OtOpcUaHost), publish path (ZB.MOM.WW.OtOpcUa.Server -> ZB.MOM.WW.OtOpcUa.Host), process names (OtOpcUa.Server -> OtOpcUa.Host). Switched nssm stop/start calls to Stop-Service/Start-Service so the script works whether the underlying service was installed via nssm or sc.exe.
This commit is contained in:
@@ -43,11 +43,11 @@ function Test-NssmService([string]$Name) {
|
||||
# Step 1: Stop in reverse dependency order
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
Step "Stopping services (OtOpcUa → OtOpcUaWonderwareHistorian → MxAccessGw)"
|
||||
Step "Stopping services (OtOpcUaHost > OtOpcUaWonderwareHistorian > MxAccessGw)"
|
||||
|
||||
foreach ($name in @('OtOpcUa', 'OtOpcUaWonderwareHistorian', 'MxAccessGw')) {
|
||||
foreach ($name in @('OtOpcUaHost', 'OtOpcUaWonderwareHistorian', 'MxAccessGw')) {
|
||||
if (Test-NssmService $name) {
|
||||
Run { nssm stop $name } "stop $name"
|
||||
Run { Stop-Service $name -Force -ErrorAction SilentlyContinue } "stop $name"
|
||||
}
|
||||
else {
|
||||
Write-Host " ($name not installed; skipping)" -ForegroundColor DarkGray
|
||||
@@ -56,7 +56,7 @@ foreach ($name in @('OtOpcUa', 'OtOpcUaWonderwareHistorian', 'MxAccessGw')) {
|
||||
|
||||
if (-not $WhatIf) {
|
||||
Start-Sleep -Seconds 3
|
||||
Get-Process MxGateway.Server, MxGateway.Worker, OtOpcUa.Server, OtOpcUa.Driver.Historian.Wonderware -ErrorAction SilentlyContinue |
|
||||
Get-Process MxGateway.Server, MxGateway.Worker, OtOpcUa.Host, OtOpcUa.Driver.Historian.Wonderware -ErrorAction SilentlyContinue |
|
||||
ForEach-Object {
|
||||
Write-Host " killing residual process $($_.ProcessName) (PID=$($_.Id))" -ForegroundColor DarkYellow
|
||||
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
|
||||
@@ -109,14 +109,14 @@ Run {
|
||||
# Step 4: Refresh OtOpcUa + Wonderware historian sidecar
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
Step "Publishing OtOpcUa server + Wonderware historian sidecar from $RepoRoot"
|
||||
Step "Publishing OtOpcUa.Host + Wonderware historian sidecar from $RepoRoot"
|
||||
|
||||
Run {
|
||||
& dotnet publish "$RepoRoot\src\Server\ZB.MOM.WW.OtOpcUa.Server" `
|
||||
& dotnet publish "$RepoRoot\src\Server\ZB.MOM.WW.OtOpcUa.Host" `
|
||||
-c Release -o (Join-Path $PublishRoot "lmxopcua") | Out-Null
|
||||
& dotnet publish "$RepoRoot\src\Drivers\ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware" `
|
||||
-c Release -o (Join-Path $PublishRoot "lmxopcua\WonderwareHistorian") | Out-Null
|
||||
} "dotnet publish (Server + sidecar)"
|
||||
} "dotnet publish (Host + sidecar)"
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Step 5: Service env block — ensure OTOPCUA_HISTORIAN_ALARM_WRITE_ENABLED
|
||||
@@ -143,16 +143,16 @@ if (Test-NssmService 'OtOpcUaWonderwareHistorian') {
|
||||
# Step 6: Start in forward dependency order
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
Step "Starting services (MxAccessGw → OtOpcUaWonderwareHistorian → OtOpcUa)"
|
||||
Step "Starting services (MxAccessGw > OtOpcUaWonderwareHistorian > OtOpcUaHost)"
|
||||
|
||||
foreach ($pair in @(
|
||||
@{ Name = 'MxAccessGw'; Wait = 4 },
|
||||
@{ Name = 'OtOpcUaWonderwareHistorian'; Wait = 4 },
|
||||
@{ Name = 'OtOpcUa'; Wait = 8 }
|
||||
@{ Name = 'OtOpcUaHost'; Wait = 8 }
|
||||
)) {
|
||||
$name = $pair.Name
|
||||
if (Test-NssmService $name) {
|
||||
Run { nssm start $name } "start $name"
|
||||
Run { Start-Service $name } "start $name"
|
||||
if (-not $WhatIf) { Start-Sleep -Seconds $pair.Wait }
|
||||
}
|
||||
else {
|
||||
@@ -167,7 +167,7 @@ foreach ($pair in @(
|
||||
Step "Smoke verification"
|
||||
|
||||
if (-not $WhatIf) {
|
||||
foreach ($name in @('MxAccessGw', 'OtOpcUaWonderwareHistorian', 'OtOpcUa')) {
|
||||
foreach ($name in @('MxAccessGw', 'OtOpcUaWonderwareHistorian', 'OtOpcUaHost')) {
|
||||
if (Test-NssmService $name) {
|
||||
$status = (Get-Service $name).Status
|
||||
$color = if ($status -eq 'Running') { 'Green' } else { 'Red' }
|
||||
|
||||
Reference in New Issue
Block a user