落地并存测服全端:智能体 Graph/路由、后台切 8180、主账与部署脚本齐备,便于线上重发与验收。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,96 +1,87 @@
|
||||
# 发布并启动新主账 8180(仅 E:\wwwroot\inquiry-new);禁止动现网 8080 / C:\yutongda
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$Root = 'E:\wwwroot\inquiry-new'
|
||||
$Jar = Join-Path $Root 'jeecg-system-start-3.5.3.jar'
|
||||
$LogDir = Join-Path $Root 'logs'
|
||||
$IncomingJar = 'C:\Users\ytd_extdev_0903\incoming\jeecg-system-start-3.5.3.jar'
|
||||
New-Item -ItemType Directory -Force -Path $Root, $LogDir | Out-Null
|
||||
# Start ledger 8180 with config overlay; never touch prod 8080 / C:\yutongda
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = "E:\wwwroot\inquiry-new"
|
||||
$Jar = Join-Path $Root "jeecg-system-start-3.5.3.jar"
|
||||
$LogDir = Join-Path $Root "logs"
|
||||
$CfgDir = Join-Path $Root "config"
|
||||
$IncomingJar = "C:\Users\ytd_extdev_0903\incoming\jeecg-system-start-3.5.3.jar"
|
||||
$IncomingCfg = "C:\Users\ytd_extdev_0903\incoming\ledger-config.zip"
|
||||
New-Item -ItemType Directory -Force -Path $Root, $LogDir, $CfgDir | Out-Null
|
||||
|
||||
if (Test-Path $IncomingJar) {
|
||||
Write-Output "=== replace jar from incoming ==="
|
||||
Copy-Item $IncomingJar $Jar -Force
|
||||
if (Test-Path $IncomingJar) { Copy-Item $IncomingJar $Jar -Force }
|
||||
if (-not (Test-Path $Jar)) { throw "jar missing" }
|
||||
if (Test-Path $IncomingCfg) {
|
||||
Expand-Archive -Path $IncomingCfg -DestinationPath $CfgDir -Force
|
||||
}
|
||||
if (-not (Test-Path (Join-Path $CfgDir "application-inquiry.yml"))) {
|
||||
@"
|
||||
cas:
|
||||
prefixUrl: http://127.0.0.1/cas-disabled
|
||||
justauth:
|
||||
enabled: true
|
||||
"@ | Set-Content (Join-Path $CfgDir "application-inquiry.yml") -Encoding UTF8
|
||||
}
|
||||
if (-not (Test-Path $Jar)) { throw "jar missing: $Jar" }
|
||||
$ji = Get-Item $Jar
|
||||
Write-Output "jar bytes=$($ji.Length) mtime=$($ji.LastWriteTime)"
|
||||
|
||||
# 加载 E:\wwwroot\.env
|
||||
Get-Content 'E:\wwwroot\.env' | ForEach-Object {
|
||||
Get-Content "E:\wwwroot\.env" | ForEach-Object {
|
||||
$line = $_.Trim()
|
||||
if (-not $line -or $line.StartsWith('#')) { return }
|
||||
$i = $line.IndexOf('=')
|
||||
if (-not $line -or $line.StartsWith("#")) { return }
|
||||
$i = $line.IndexOf("=")
|
||||
if ($i -lt 1) { return }
|
||||
$k = $line.Substring(0, $i).Trim()
|
||||
$v = $line.Substring($i + 1).Trim()
|
||||
if ($v.StartsWith('"') -and $v.EndsWith('"')) { $v = $v.Substring(1, $v.Length - 2) }
|
||||
[Environment]::SetEnvironmentVariable($k, $v, 'Process')
|
||||
Set-Item -Path "Env:$k" -Value $v
|
||||
$v = $line.Substring($i + 1).Trim().Trim('"')
|
||||
Set-Item -Path ("Env:" + $k) -Value $v
|
||||
}
|
||||
|
||||
if (-not $env:YTD_REDIS_PASSWORD -and $env:REDIS_URL) {
|
||||
if ($env:REDIS_URL -match 'redis://:([^@]+)@') {
|
||||
$env:YTD_REDIS_PASSWORD = $Matches[1]
|
||||
} elseif ($env:REDIS_URL -match 'redis://[^:]+:([^@]+)@') {
|
||||
$env:YTD_REDIS_PASSWORD = $Matches[1]
|
||||
}
|
||||
if ($env:REDIS_URL -match "redis://:([^@]+)@") { $env:YTD_REDIS_PASSWORD = $Matches[1] }
|
||||
elseif ($env:REDIS_URL -match "redis://[^:]+:([^@]+)@") { $env:YTD_REDIS_PASSWORD = $Matches[1] }
|
||||
}
|
||||
if (-not $env:YTD_REDIS_HOST) { $env:YTD_REDIS_HOST = '127.0.0.1' }
|
||||
$env:YTD_REDIS_HOST = '127.0.0.1'
|
||||
$env:LEDGER_PORT = '8180'
|
||||
if (-not $env:YTD_REDIS_HOST) { $env:YTD_REDIS_HOST = "10.206.0.14" }
|
||||
if (-not $env:YTD_REDIS_PORT) { $env:YTD_REDIS_PORT = "6379" }
|
||||
if (-not $env:YTD_REDIS_DB) { $env:YTD_REDIS_DB = "1" }
|
||||
$env:LEDGER_PORT = "8180"
|
||||
Write-Host ("MYSQL_DB=" + $env:MYSQL_DB + " MYSQL_HOST=" + $env:MYSQL_HOST + " REDIS_HOST=" + $env:YTD_REDIS_HOST + " REDIS_DB=" + $env:YTD_REDIS_DB)
|
||||
|
||||
Write-Host "MYSQL_DB=$env:MYSQL_DB MYSQL_HOST=$env:MYSQL_HOST LEDGER_PORT=$env:LEDGER_PORT"
|
||||
|
||||
# 只停 inquiry-new 的 8180,绝不碰 yutongda 8080
|
||||
Get-CimInstance Win32_Process -Filter "Name='java.exe'" | ForEach-Object {
|
||||
if ($_.CommandLine -and $_.CommandLine -like '*inquiry-new*jeecg-system-start*') {
|
||||
Write-Host "stop pid=$($_.ProcessId)"
|
||||
if ($_.CommandLine -and $_.CommandLine -like "*inquiry-new*jeecg-system-start*") {
|
||||
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
Get-NetTCPConnection -LocalPort 8180 -ErrorAction SilentlyContinue |
|
||||
Select-Object -ExpandProperty OwningProcess -Unique |
|
||||
ForEach-Object {
|
||||
$p = Get-CimInstance Win32_Process -Filter "ProcessId=$_"
|
||||
if ($p -and $p.CommandLine -like '*inquiry-new*') {
|
||||
Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
$Java = 'C:\yutongda\tools\jdk8\bin\java.exe'
|
||||
if (-not (Test-Path $Java)) { throw "java missing $Java" }
|
||||
$Out = Join-Path $LogDir 'stdout.log'
|
||||
$Err = Join-Path $LogDir 'stderr.log'
|
||||
$Java = "C:\yutongda\tools\jdk8\bin\java.exe"
|
||||
$Out = Join-Path $LogDir "stdout.log"
|
||||
$Err = Join-Path $LogDir "stderr.log"
|
||||
# truncate logs
|
||||
Set-Content $Out -Value "" -Encoding UTF8
|
||||
Set-Content $Err -Value "" -Encoding UTF8
|
||||
$arg = @(
|
||||
'-jar', $Jar,
|
||||
'--spring.profiles.active=inquiry',
|
||||
"--server.port=$env:LEDGER_PORT"
|
||||
"-jar", $Jar,
|
||||
"--spring.profiles.active=inquiry",
|
||||
"--server.port=8180",
|
||||
"--spring.config.additional-location=optional:file:./config/",
|
||||
"--cas.prefixUrl=http://127.0.0.1/cas-disabled"
|
||||
)
|
||||
Write-Host "starting $Java $($arg -join ' ')"
|
||||
Write-Host ("starting java jar inquiry profile redis=" + $env:YTD_REDIS_HOST + ":" + $env:YTD_REDIS_PORT + "/" + $env:YTD_REDIS_DB)
|
||||
$p = Start-Process -FilePath $Java -ArgumentList $arg -WorkingDirectory $Root -RedirectStandardOutput $Out -RedirectStandardError $Err -PassThru -WindowStyle Hidden
|
||||
Write-Host "started pid=$($p.Id)"
|
||||
Write-Host ("started pid=" + $p.Id)
|
||||
|
||||
# 等启动(最长约 90s)
|
||||
$ok = $false
|
||||
for ($i = 1; $i -le 18; $i++) {
|
||||
for ($i = 1; $i -le 24; $i++) {
|
||||
Start-Sleep -Seconds 5
|
||||
try {
|
||||
$r = Invoke-WebRequest -Uri 'http://127.0.0.1:8180/jeecgboot/' -UseBasicParsing -TimeoutSec 5
|
||||
Write-Host "health try=$i status=$($r.StatusCode)"
|
||||
$r = Invoke-WebRequest -Uri "http://127.0.0.1:8180/jeecgboot/" -UseBasicParsing -TimeoutSec 5
|
||||
Write-Host ("health try=" + $i + " status=" + $r.StatusCode)
|
||||
$ok = $true
|
||||
break
|
||||
} catch {
|
||||
Write-Host "health try=$i pending"
|
||||
Write-Host ("health try=" + $i + " pending")
|
||||
}
|
||||
}
|
||||
if (-not $ok) {
|
||||
Write-Host '--- stderr tail ---'
|
||||
if (Test-Path $Err) { Get-Content $Err -Tail 50 }
|
||||
throw 'ledger 8180 health failed'
|
||||
if (Test-Path $Err) { Get-Content $Err -Tail 60 }
|
||||
throw "ledger 8180 health failed"
|
||||
}
|
||||
|
||||
# 确认现网 8080 仍在
|
||||
$prod = Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if (-not $prod) { throw 'CRITICAL: prod 8080 down after start' }
|
||||
Write-Output 'LEDGER_8180_OK'
|
||||
Write-Output "PROD_8080_OK pid=$($prod.OwningProcess)"
|
||||
if (-not $prod) { throw "CRITICAL: prod 8080 down" }
|
||||
Write-Output "LEDGER_8180_OK"
|
||||
Write-Output ("PROD_8080_OK pid=" + $prod.OwningProcess)
|
||||
|
||||
Reference in New Issue
Block a user