初始化询价智能体新仓:同步本地工程并排除密钥与 .env。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# 服务器侧:发布新后台静态到 admin\releases\<id>\dist,并切换 admin\current 联接
|
||||
# 根目录:E:\wwwroot。禁止动 C:\yutongda。Nginx conf 必须无 BOM。
|
||||
$ErrorActionPreference = "Stop"
|
||||
$IncomingZip = "C:\Users\ytd_extdev_0903\incoming\admin-dist.zip"
|
||||
$IncomingConf = "C:\Users\ytd_extdev_0903\incoming\ai.conf.cutover-8910"
|
||||
$Root = "E:\wwwroot"
|
||||
$NginxConf = "C:\nginx-1.18.0\myconf\ai.conf"
|
||||
$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 $IncomingZip" }
|
||||
if (-not (Test-Path $IncomingConf)) { throw "missing $IncomingConf" }
|
||||
|
||||
Write-Output "=== backup nginx ==="
|
||||
Copy-Item $NginxConf "$NginxConf.bak-before-admin-$Stamp" -Force
|
||||
|
||||
Write-Output "=== install release dist ==="
|
||||
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"))) { throw "index.html missing" }
|
||||
|
||||
Write-Output "=== switch admin\\current junction ==="
|
||||
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" }
|
||||
Write-Output "CURRENT_OK=$Current -> $RelDist"
|
||||
|
||||
Write-Output "=== nginx conf no BOM ==="
|
||||
$bytes = [System.IO.File]::ReadAllBytes($IncomingConf)
|
||||
if ($bytes.Length -ge 3 -and $bytes[0] -eq 239 -and $bytes[1] -eq 187 -and $bytes[2] -eq 191) {
|
||||
$list = New-Object System.Collections.Generic.List[byte]
|
||||
for ($i = 3; $i -lt $bytes.Length; $i++) { [void]$list.Add($bytes[$i]) }
|
||||
$bytes = $list.ToArray()
|
||||
}
|
||||
[System.IO.File]::WriteAllBytes($NginxConf, $bytes)
|
||||
|
||||
Set-Location "C:\nginx-1.18.0"
|
||||
& .\nginx.exe -t
|
||||
if ($LASTEXITCODE -ne 0) { throw "nginx -t failed" }
|
||||
|
||||
Get-Process nginx -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 1
|
||||
try {
|
||||
Start-Service Nginx1.18 -ErrorAction Stop
|
||||
Write-Output "SERVICE_STARTED"
|
||||
} catch {
|
||||
Start-Process -FilePath "C:\nginx-1.18.0\nginx.exe" -WorkingDirectory "C:\nginx-1.18.0" -WindowStyle Hidden
|
||||
Write-Output "EXE_STARTED"
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
Write-Output "DONE"
|
||||
Reference in New Issue
Block a user