# 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) { 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 } Get-Content "E:\wwwroot\.env" | ForEach-Object { $line = $_.Trim() 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().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 (-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) Get-CimInstance Win32_Process -Filter "Name='java.exe'" | ForEach-Object { if ($_.CommandLine -and $_.CommandLine -like "*inquiry-new*jeecg-system-start*") { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } } Start-Sleep -Seconds 2 $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=8180", "--spring.config.additional-location=optional:file:./config/", "--cas.prefixUrl=http://127.0.0.1/cas-disabled" ) 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) $ok = $false 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) $ok = $true break } catch { Write-Host ("health try=" + $i + " pending") } } if (-not $ok) { if (Test-Path $Err) { Get-Content $Err -Tail 60 } throw "ledger 8180 health failed" } $prod = Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1 if (-not $prod) { throw "CRITICAL: prod 8080 down" } Write-Output "LEDGER_8180_OK" Write-Output ("PROD_8080_OK pid=" + $prod.OwningProcess)