Script d'arrêt
This commit is contained in:
1 parent
330ccaa9d2
commit
014adaf22e
1 file changed
+31
@@ -0,0 +1,31 @@
|
||||
# Stoppe proprement les processus laissés par "npm run dev"
|
||||
# (backend:4000, frontend:5173, mcp-server:4100) même si le terminal
|
||||
# d'origine a été fermé sans Ctrl+C.
|
||||
|
||||
$ports = @(4000, 5173, 4100)
|
||||
$killed = 0
|
||||
|
||||
foreach ($port in $ports) {
|
||||
$lines = netstat -ano | Select-String ":$port\s" | Select-String "LISTENING"
|
||||
if (-not $lines) {
|
||||
Write-Host "Port $port : rien à l'écoute." -ForegroundColor DarkGray
|
||||
continue
|
||||
}
|
||||
$pids = $lines | ForEach-Object { ($_ -split '\s+')[-1] } | Sort-Object -Unique
|
||||
foreach ($processId in $pids) {
|
||||
try {
|
||||
$proc = Get-Process -Id $processId -ErrorAction Stop
|
||||
Write-Host "Port $port : arrêt de $($proc.ProcessName) (PID $processId)" -ForegroundColor Yellow
|
||||
Stop-Process -Id $processId -Force
|
||||
$killed++
|
||||
} catch {
|
||||
Write-Host "Port $port : PID $processId déjà terminé." -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($killed -eq 0) {
|
||||
Write-Host "Aucun processus de dev actif à arrêter." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "$killed processus arrêté(s)." -ForegroundColor Green
|
||||
}
|
||||
Reference in new issue
Block a user