23 lines
845 B
PowerShell
23 lines
845 B
PowerShell
# 停止 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 '完成。'
|