初始化系统融合软件代码仓库
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
[CmdletBinding()]
|
||||
param([switch]$RestartRunningServices)
|
||||
$ErrorActionPreference='Stop'
|
||||
if(-not $RestartRunningServices){throw '此步骤会短暂停止PXHJ采集并刷新融合总控。需明确确认后使用 -RestartRunningServices。'}
|
||||
$projectRoot=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$pxhjRoot='E:\pxhj'
|
||||
$coordinatorRoot=Join-Path $projectRoot 'runtime/coordinator'
|
||||
$sourcePxhj=Join-Path $projectRoot 'runtime/console-pxhj-build/pxhj-server-0.1.0.jar'
|
||||
$targetPxhj=Join-Path $pxhjRoot 'backend/target/pxhj-server-0.1.0.jar'
|
||||
$sourceXtrh=Join-Path $projectRoot 'target/xtrh-services-1.0.0.jar'
|
||||
foreach($file in @($sourcePxhj,$sourceXtrh)){if(-not(Test-Path -LiteralPath $file)){throw '缺少已验证构建产物。'}}
|
||||
$listeners=@(Get-NetTCPConnection -State Listen -LocalPort 8088 -ErrorAction SilentlyContinue)
|
||||
$backendPid=0
|
||||
$backendTicks=0
|
||||
if($listeners.Count){
|
||||
$backendPid=[int]$listeners[0].OwningProcess
|
||||
$process=Get-Process -Id $backendPid
|
||||
$backendTicks=$process.StartTime.ToUniversalTime().Ticks
|
||||
$command=Get-CimInstance Win32_Process -Filter ('ProcessId='+$backendPid)
|
||||
$jar=[regex]::Match([string]$command.CommandLine,'(?i)-jar\s+(?:"(?<p>[^"]+)"|(?<p>\S+))').Groups['p'].Value
|
||||
if([IO.Path]::GetFullPath($jar) -ne [IO.Path]::GetFullPath($targetPxhj)){throw '8088不是目标PXHJ进程,未停止任何程序。'}
|
||||
}
|
||||
$backup=Join-Path $projectRoot ('runtime/console-activation-backup-'+(Get-Date -Format 'yyyyMMdd-HHmmss'))
|
||||
New-Item -ItemType Directory -Force -Path $backup | Out-Null
|
||||
Copy-Item -LiteralPath $targetPxhj -Destination (Join-Path $backup 'pxhj-server.jar')
|
||||
Copy-Item -LiteralPath (Join-Path $coordinatorRoot 'xtrh-services.jar') -Destination (Join-Path $backup 'xtrh-services.jar')
|
||||
if($backendPid){
|
||||
$current=Get-Process -Id $backendPid -ErrorAction Stop
|
||||
if($current.StartTime.ToUniversalTime().Ticks -ne $backendTicks){throw 'PXHJ进程身份已变化,未停止。'}
|
||||
Stop-Process -Id $backendPid
|
||||
Wait-Process -Id $backendPid -Timeout 15 -ErrorAction SilentlyContinue
|
||||
}
|
||||
& (Join-Path $projectRoot 'scripts/Stop-Xtrh.ps1') -InstallRoot $coordinatorRoot
|
||||
Copy-Item -LiteralPath $sourcePxhj -Destination $targetPxhj
|
||||
Copy-Item -LiteralPath $sourceXtrh -Destination (Join-Path $coordinatorRoot 'xtrh-services.jar')
|
||||
foreach($pair in @(@{source=$sourcePxhj;target=$targetPxhj},@{source=$sourceXtrh;target=(Join-Path $coordinatorRoot 'xtrh-services.jar')})){
|
||||
if((Get-FileHash -LiteralPath $pair.source).Hash -ne (Get-FileHash -LiteralPath $pair.target).Hash){throw '加载前JAR校验失败。'}
|
||||
}
|
||||
$env:JAVA_HOME='C:\Program Files\Java\jdk-25.0.2'
|
||||
$env:PATH=$env:JAVA_HOME+'\bin;'+$env:PATH
|
||||
& (Join-Path $projectRoot 'scripts/Start-Xtrh.ps1') -InstallRoot $coordinatorRoot -JavaHome $env:JAVA_HOME
|
||||
& (Join-Path $pxhjRoot 'scripts/start-dev.ps1') -SkipBuild -BackendOnly
|
||||
Write-Output ('新页面和真实采集桥接已加载;原包备份:'+$backup)
|
||||
Reference in New Issue
Block a user