优化 gateway 停止脚本在 PID 已退出场景下的日志表现。

在 stop_gateway 的进程终止流程中先检测进程是否存在,避免误报 Failed to stop 警告,保留端口回退清理逻辑并让 stop_all 输出更稳定可读。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-29 01:20:58 +08:00
parent 26562b1ca4
commit b6dd8edc5d

View file

@ -14,6 +14,16 @@ function Warn([string]$msg) {
}
function Kill-ProcId([int]$procId) {
$exists = $null
try {
$exists = Get-Process -Id $procId -ErrorAction SilentlyContinue
} catch {
$exists = $null
}
if (-not $exists) {
Write-Host "PID=$procId already exited" -ForegroundColor DarkGray
return $true
}
try {
Stop-Process -Id $procId -Force
Write-Host "Stopped PID=$procId" -ForegroundColor Green