elderly-health-platform/dev/stop-all.ps1
2026-10-16 20:17:14 +08:00

23 lines
845 B
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 停止 elderly-health-platform 本地服务:Redis(6380) + yudao-server(48080) + Vue3 管理端(48081)
# 用法:powershell -ExecutionPolicy Bypass -File .\dev\stop-all.ps1
foreach ($port in 48082, 48081, 48080, 6380) {
$lines = netstat -ano | Select-String 'LISTENING' | Select-String ":$port\s"
if (-not $lines) { Write-Host "端口 $port 未监听,跳过"; continue }
$pids = $lines | ForEach-Object {
($_ -split '\s+') | Where-Object { $_ -match '^\d+$' } | Select-Object -Last 1
} | Sort-Object -Unique
foreach ($processId in $pids) {
try {
Stop-Process -Id $processId -Force -ErrorAction Stop
Write-Host "已停止端口 $port 对应进程 (PID $processId)"
} catch {
Write-Host "端口 $port 进程 $processId 停止失败:$($_.Exception.Message)"
}
}
}
Write-Host '完成。'