Files
2026-10-20 11:33:20 +08:00

28 lines
1.9 KiB
PowerShell

$ErrorActionPreference='Stop'
$repo='D:\project\baiyue-firstleg'
. "$repo\scripts\local-env.ps1"
$env:LASTLEG_DB_PASSWORD=$env:AUTH_DB_PASSWORD
$env:LASTLEG_DB_USERNAME='root'
$env:LASTLEG_DB_URL='jdbc:mysql://127.0.0.1:3306/baiyue_lastleg?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true'
$env:FIRSTLEG_DB_URL='jdbc:mysql://127.0.0.1:3306/baiyue_firstleg?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true'
$env:WAREHOUSE_SERVICE_URL='http://127.0.0.1:9205'
$env:ORDER_SERVICE_URL='http://127.0.0.1:9204'
$env:FILE_SERVICE_URL='http://127.0.0.1:9206'
$env:DOMESTIC_WAREHOUSE_URL='http://127.0.0.1:9205'
$env:WAREHOUSE_OVERSEAS_SERVICE_URL='http://127.0.0.1:9305'
$env:FIRSTLEG_SERVICE_URL='http://127.0.0.1:9202'
$env:LASTLEG_SERVICE_URL='http://127.0.0.1:9303'
foreach($entry in @(@{Port=9202;Name='firstleg'})) {
$entry.Id=(Get-NetTCPConnection -LocalPort $entry.Port -State Listen | Select-Object -First 1).OwningProcess
$process=Get-CimInstance Win32_Process -Filter "ProcessId=$($entry.Id)"
if(!$process -or $process.CommandLine -notmatch "com\.baiyue\.$($entry.Name)\.") {throw '原服务进程身份不匹配'}
$cp=[regex]::Match($process.CommandLine,'(?:-classpath|-cp)\s+(?:"([^"]+)"|(\S+))')
$classpath=if($cp.Groups[1].Success){$cp.Groups[1].Value}else{$cp.Groups[2].Value}
$main=[regex]::Match($process.CommandLine,'com\.baiyue\.[\w.]+Application').Value
if(!$classpath -or !$main){throw '无法保留原服务启动类路径'}
Stop-Process -Id $entry.Id
$new=Start-Process -FilePath $process.ExecutablePath -ArgumentList "-Dfile.encoding=UTF-8 -Xmx1024m -cp `"$classpath`" $main" -WorkingDirectory $repo -WindowStyle Hidden -PassThru -RedirectStandardOutput "$PSScriptRoot\$($entry.Name)-tabs-runtime.log" -RedirectStandardError "$PSScriptRoot\$($entry.Name)-tabs-runtime.err.log"
"$($entry.Name) PID=$($new.Id)"
}