| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- # One-click Phase2: rebuild fs-saas-company, restart, Java migrate + smoke + verify
- # Usage:
- # cd d:\ylrz_saas_new\java\scripts
- # .\run_lobster_phase2_java.ps1 -TenantId 1 -CompanyId 1
- param(
- [string]$ApiBase = "http://127.0.0.1:8006",
- [int]$TenantId = 1,
- [int]$CompanyId = 1,
- [string]$OpsSecret = "lobster-dev-ops",
- [switch]$SkipBuild,
- [switch]$SkipRestart
- )
- $ErrorActionPreference = "Stop"
- $javaHome = "D:\AICALL\jdk-17.0.12+7"
- $mvn = "D:\maven\apache-maven-3.9.15\bin\mvn.cmd"
- $jarDir = "d:\ylrz_saas_new\java\fs-saas-company"
- $jarPath = "$jarDir\target\fs-saas-company.jar"
- $logPath = "d:\ylrz_saas_new\java\fs-saas-company-phase2-run.log"
- $headers = @{
- "Content-Type" = "application/json"
- "X-Lobster-Ops-Secret" = $OpsSecret
- }
- $qs = "tenantId=$TenantId"
- function Invoke-Phase2 {
- param([string]$Method, [string]$Path)
- $uri = "$($ApiBase.TrimEnd('/'))$Path" + "?$qs"
- if ($Method -eq "GET") {
- return Invoke-RestMethod -Uri $uri -Method GET -Headers $headers -TimeoutSec 120
- }
- return Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -TimeoutSec 180
- }
- Write-Host "=== Phase2 Java ops pipeline ===" -ForegroundColor Cyan
- if (-not $SkipBuild) {
- Write-Host "[1/4] mvn package fs-saas-company ..." -ForegroundColor Yellow
- $env:JAVA_HOME = $javaHome
- $env:PATH = "$javaHome\bin;$env:PATH"
- Push-Location "d:\ylrz_saas_new\java"
- & $mvn -pl fs-saas-company -am package -DskipTests -q
- if ($LASTEXITCODE -ne 0) { throw "Maven build failed" }
- Pop-Location
- }
- if (-not $SkipRestart) {
- Write-Host "[2/4] restart fs-saas-company :8006 ..." -ForegroundColor Yellow
- Get-NetTCPConnection -LocalPort 8006 -ErrorAction SilentlyContinue |
- ForEach-Object { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue }
- Start-Sleep -Seconds 2
- $env:JAVA_HOME = $javaHome
- Start-Process -FilePath "$javaHome\bin\java.exe" `
- -ArgumentList @("-jar", $jarPath, "--spring.profiles.active=dev") `
- -WorkingDirectory $jarDir `
- -RedirectStandardOutput $logPath `
- -RedirectStandardError "${logPath}.err" `
- -WindowStyle Hidden
- $deadline = (Get-Date).AddMinutes(5)
- do {
- Start-Sleep -Seconds 3
- try {
- $r = Invoke-WebRequest -Uri "$ApiBase/" -UseBasicParsing -TimeoutSec 5 -SkipHttpErrorCheck
- if ($r.StatusCode -ge 200 -and $r.StatusCode -lt 600) { break }
- } catch {
- if ((Get-Date) -gt $deadline) { throw "Service not up on $ApiBase" }
- }
- } while ((Get-Date) -lt $deadline)
- Write-Host " service is up" -ForegroundColor Green
- } else {
- Write-Host "[2/4] skip restart" -ForegroundColor DarkGray
- }
- Write-Host "[3/4] POST run-all (migrate + smoke x2 + verify) ..." -ForegroundColor Yellow
- $result = Invoke-Phase2 -Method POST -Path "/api/lobster/admin/phase2/run-all/$CompanyId"
- $result | ConvertTo-Json -Depth 6
- Write-Host "[4/4] summary" -ForegroundColor Yellow
- $smoke = $result.smoke
- if ($smoke.passed -eq $true) {
- Write-Host "PASS replay_buffer increased by $($smoke.delta) ($($smoke.hotReplayRowsBefore) -> $($smoke.hotReplayRowsAfter))" -ForegroundColor Green
- exit 0
- } else {
- Write-Host "FAIL smoke check: $($smoke | ConvertTo-Json -Compress)" -ForegroundColor Red
- exit 2
- }
|