From 014adaf22e9a21c697841c95763eefc34295db7a Mon Sep 17 00:00:00 2001 From: Olivier Date: Sun, 16 Aug 2026 16:29:16 +0200 Subject: [PATCH] =?UTF-8?q?Script=20d'arr=C3=AAt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/stop-dev.ps1 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/stop-dev.ps1 diff --git a/scripts/stop-dev.ps1 b/scripts/stop-dev.ps1 new file mode 100644 index 0000000..aceedee --- /dev/null +++ b/scripts/stop-dev.ps1 @@ -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 +}