From 916c3142d4f68048b272f8797e402bada73aa2b8 Mon Sep 17 00:00:00 2001 From: troogs Date: Fri, 10 Apr 2026 05:48:37 +0200 Subject: [PATCH] Remove unused Blazorise script reference and add kill-port script for managing listening processes --- FoodsharingSiegen.Server/Pages/_Layout.cshtml | 1 - .../wwwroot/buildinfo.txt | 1 + Scripts/kill-port-56000.ps1 | 53 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 FoodsharingSiegen.Server/wwwroot/buildinfo.txt create mode 100644 Scripts/kill-port-56000.ps1 diff --git a/FoodsharingSiegen.Server/Pages/_Layout.cshtml b/FoodsharingSiegen.Server/Pages/_Layout.cshtml index 226eb84..d13b3bb 100644 --- a/FoodsharingSiegen.Server/Pages/_Layout.cshtml +++ b/FoodsharingSiegen.Server/Pages/_Layout.cshtml @@ -43,7 +43,6 @@ - \ No newline at end of file diff --git a/FoodsharingSiegen.Server/wwwroot/buildinfo.txt b/FoodsharingSiegen.Server/wwwroot/buildinfo.txt new file mode 100644 index 0000000..238dd7b --- /dev/null +++ b/FoodsharingSiegen.Server/wwwroot/buildinfo.txt @@ -0,0 +1 @@ +20260410 diff --git a/Scripts/kill-port-56000.ps1 b/Scripts/kill-port-56000.ps1 new file mode 100644 index 0000000..b1b971c --- /dev/null +++ b/Scripts/kill-port-56000.ps1 @@ -0,0 +1,53 @@ +param( + [int]$Port = 56000 +) + +$killedAny = $false + +# Try modern cmdlet first. +$connections = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue +if ($connections) { + $pids = $connections | Select-Object -ExpandProperty OwningProcess -Unique + foreach ($procId in $pids) { + try { + Stop-Process -Id $procId -Force -ErrorAction Stop + Write-Host "Stopped process $procId listening on port $Port." + $killedAny = $true + } + catch { + Write-Warning "Failed to stop process ${procId}: $($_.Exception.Message)" + } + } +} + +# Fallback for environments where Get-NetTCPConnection is unavailable. +if (-not $killedAny) { + $netstatLines = netstat -ano | Select-String ":$Port\s" + $listenLines = $netstatLines | Where-Object { $_.Line -match "LISTENING" } + + $fallbackPids = @() + foreach ($line in $listenLines) { + $parts = ($line.Line -replace "\s+", " ").Trim().Split(" ") + if ($parts.Length -ge 5) { + $fallbackPids += $parts[-1] + } + } + + $fallbackPids = $fallbackPids | Sort-Object -Unique + foreach ($pidText in $fallbackPids) { + if ($pidText -match "^\d+$") { + try { + Stop-Process -Id ([int]$pidText) -Force -ErrorAction Stop + Write-Host "Stopped process $pidText listening on port $Port." + $killedAny = $true + } + catch { + Write-Warning "Failed to stop process ${pidText}: $($_.Exception.Message)" + } + } + } +} + +if (-not $killedAny) { + Write-Host "No listening process found on port $Port." +}