Files
jiang13-bbs/stop.ps1
freefire d032668c66 chore(dev): stop.bat 仅 ASCII,避免 Windows GBK 乱码断行
cmd 按 ANSI 解析 .bat,中文提示改由带 BOM 的 stop.ps1 输出。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 07:44:26 +08:00

31 lines
842 B
PowerShell

# Kill process trees listening on given ports. Default: :3000 frontend / :3001 backend.
# Called by stop.bat; or: powershell -File stop.ps1
param(
[int[]]$Ports = @(3000, 3001)
)
$ErrorActionPreference = 'SilentlyContinue'
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Write-Host "Stopping listeners on :3000 / :3001 (process trees)..."
Write-Host ""
foreach ($port in $Ports) {
$pids = @(
Get-NetTCPConnection -LocalPort $port -State Listen |
Select-Object -ExpandProperty OwningProcess -Unique
)
if (-not $pids -or $pids.Count -eq 0) {
Write-Host " :$port idle"
continue
}
foreach ($procId in $pids) {
if ($procId -le 0) { continue }
Write-Host " :$port -> PID $procId (tree)"
& taskkill.exe /T /F /PID $procId | Out-Null
}
}
Write-Host ""
Write-Host "Port cleanup finished."