Files
inquiry_robot/deploy/_remote_refresh_admin_dist.ps1
T

38 lines
1.7 KiB
PowerShell

# 仅刷新后台静态(不改 Nginx、不动 8080)。依赖已切流到 8180。
$ErrorActionPreference = 'Stop'
$IncomingZip = 'C:\Users\ytd_extdev_0903\incoming\admin-dist.zip'
$Root = 'E:\wwwroot'
$Stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$RelId = 'admin-' + $Stamp
$RelDist = Join-Path $Root ('admin\releases\' + $RelId + '\dist')
$Current = Join-Path $Root 'admin\current'
if (-not (Test-Path $IncomingZip)) { throw 'missing admin-dist.zip' }
$ledger = Get-NetTCPConnection -LocalPort 8180 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $ledger) { throw 'CRITICAL: 8180 not listening' }
$prod = Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $prod) { throw 'CRITICAL: prod 8080 down' }
New-Item -ItemType Directory -Force -Path $RelDist | Out-Null
Expand-Archive -Path $IncomingZip -DestinationPath $RelDist -Force
if (-not (Test-Path (Join-Path $RelDist 'index.html'))) {
$inner = Get-ChildItem $RelDist -Directory | Select-Object -First 1
if ($inner -and (Test-Path (Join-Path $inner.FullName 'index.html'))) {
$RelDist = $inner.FullName
}
}
if (-not (Test-Path (Join-Path $RelDist 'index.html'))) { throw 'index.html missing' }
if (Test-Path $Current) {
cmd /c "rmdir `"$Current`"" | Out-Null
if (Test-Path $Current) { Remove-Item $Current -Recurse -Force }
}
cmd /c "mklink /J `"$Current`" `"$RelDist`""
if (-not (Test-Path (Join-Path $Current 'index.html'))) { throw 'current index missing' }
$bytes = (Get-Item $IncomingZip).Length
Write-Output ("ADMIN_DIST_REFRESH_OK current=" + $Current)
Write-Output ("rel=" + $RelDist)
Write-Output ("zip_bytes=" + $bytes)
Write-Output ("PROD_8080_OK pid=" + $prod.OwningProcess)