<# .SYNOPSIS Stoppt alle laufenden GerbilManager-Prozesse (AppHost + Kindprozesse). .NOTES Beendet dotnet-AppHost-Prozesse und wartet darauf, dass Docker-Container von Aspire selbst heruntergefahren werden. #> Set-StrictMode -Version Latest $ErrorActionPreference = "SilentlyContinue" $pidFile = Join-Path $PSScriptRoot "..\gerbilmanager.pid" # Ueber gespeicherte PID stoppen (wenn vorhanden) if (Test-Path $pidFile) { $savedPid = Get-Content $pidFile -Raw | ForEach-Object { $_.Trim() } $proc = Get-Process -Id $savedPid -ErrorAction SilentlyContinue if ($proc) { Write-Host "Beende Prozess PID $savedPid ($($proc.Name))..." Stop-Process -Id $savedPid -Force Remove-Item $pidFile -Force } } # Alle dotnet-Prozesse stoppen, die den AppHost als Elternprozess haben $appHostProcs = Get-Process -Name "dotnet" -ErrorAction SilentlyContinue | Where-Object { $_.MainModule.FileName -like "*dotnet*" } foreach ($p in $appHostProcs) { $cmdLine = (Get-CimInstance Win32_Process -Filter "ProcessId = $($p.Id)").CommandLine if ($cmdLine -like "*GerbilManager.AppHost*") { Write-Host "Beende dotnet-AppHost (PID $($p.Id))..." Stop-Process -Id $p.Id -Force } } # Vite-Dev-Server stoppen (node-Prozess auf Port 5173) $nodePids = (netstat -ano | Select-String ":5173").ToString() -split "\s+" | Where-Object { $_ -match "^\d+$" } | Select-Object -Unique foreach ($nPid in $nodePids) { $np = Get-Process -Id $nPid -ErrorAction SilentlyContinue if ($np -and $np.Name -in @("node", "npm")) { Write-Host "Beende Vite-Dev-Server (PID $nPid)..." Stop-Process -Id $nPid -Force } } Write-Host "GerbilManager wurde gestoppt." Write-Host "Hinweis: Der Postgres-Docker-Container laeuft weiterhin (Aspire managed ihn)." Write-Host " Zum Stoppen: docker stop $(docker ps --filter 'name=postgres' --format '{{.Names}}' 2>$null)"