fix: ensure authenticated graceful shutdown exits process and sort live activity feed by timestamp descending
This commit is contained in:
1 parent
3efee96230
commit
91d5565141
5 files changed
+46
-22
No files matched your search
@@ -35,12 +35,8 @@ deploy-win: deploy-server deploy-stub-win deploy-nvim-win deploy-rules-win
|
||||
# Stop the background server
|
||||
stop port="3000":
|
||||
@Write-Host "Shutting down MCP server gracefully on port {{port}}..." -ForegroundColor Cyan
|
||||
-$token = Get-Content "$env:USERPROFILE\.gemini\mcp_memory\admin.token" -ErrorAction SilentlyContinue; if ($token) { Invoke-RestMethod -Uri "http://127.0.0.1:{{port}}/shutdown" -Method Post -Headers @{ Authorization = "Bearer $token" } -ErrorAction SilentlyContinue } else { Invoke-RestMethod -Uri "http://127.0.0.1:{{port}}/shutdown" -Method Post -ErrorAction SilentlyContinue }
|
||||
$stopped = $false; for ($i = 1; $i -le 10; $i++) { if (-not (Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue)) { $stopped = $true; Write-Host '✅ Server on port {{port}} shut down gracefully.' -ForegroundColor Green; break }; Start-Sleep -Seconds 1 }
|
||||
if (-not $stopped -and (Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue)) { Write-Host '⚠️ Server did not exit gracefully within 10s. Force killing process...' -ForegroundColor Yellow; Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }; Start-Sleep -Seconds 2 }
|
||||
for ($i = 1; $i -le 5; $i++) { if (-not (Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue)) { break }; Start-Sleep -Seconds 1 }
|
||||
Start-Sleep -Seconds 2
|
||||
Write-Host '✅ Shutdown complete. Port {{port}} is free.' -ForegroundColor Green
|
||||
-& { $token = Get-Content "$env:USERPROFILE\.gemini\mcp_memory\admin.token" -ErrorAction SilentlyContinue; if ($token) { $hdr = @{ Authorization = "Bearer $($token.Trim())" }; Invoke-RestMethod -Uri "http://127.0.0.1:{{port}}/shutdown" -Method Post -Headers $hdr -ErrorAction SilentlyContinue } else { Invoke-RestMethod -Uri "http://127.0.0.1:{{port}}/shutdown" -Method Post -ErrorAction SilentlyContinue }; $stopped = $false; for ($i = 1; $i -le 10; $i++) { $conn = Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue; $proc = Get-Process mcp-memory-server -ErrorAction SilentlyContinue; if (-not $conn -and -not $proc) { $stopped = $true; Write-Host '✅ Server process and port {{port}} fully terminated.' -ForegroundColor Green; break }; Start-Sleep -Seconds 1 }; if (-not $stopped) { Write-Host '⚠️ Server process did not exit within 10s. Force killing process...' -ForegroundColor Yellow; Get-Process mcp-memory-server -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue; Get-NetTCPConnection -LocalPort {{port}} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }; Start-Sleep -Seconds 2 } }
|
||||
@Write-Host "✅ Shutdown complete. Port {{port}} and process are free." -ForegroundColor Green
|
||||
|
||||
# Start the server in the background (nohup equivalent)
|
||||
start port="3000":
|
||||
@@ -71,6 +67,8 @@ build-stub-win:
|
||||
# =========================================================
|
||||
deploy-server:
|
||||
@Write-Host "Deploying Windows Server..." -ForegroundColor Cyan
|
||||
-Stop-Process -Name mcp-memory-server -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 1
|
||||
-if (Test-Path "C:\Users\reazul.ashraf\.local\bin\mcp-memory-server.exe") { Move-Item -Force "C:\Users\reazul.ashraf\.local\bin\mcp-memory-server.exe" "C:\Users\reazul.ashraf\.local\bin\mcp-memory-server.exe.old" -ErrorAction SilentlyContinue; Remove-Item -Force "C:\Users\reazul.ashraf\.local\bin\mcp-memory-server.exe.old" -ErrorAction SilentlyContinue }
|
||||
Copy-Item -Force target\release\mcp-memory-server.exe "C:\Users\reazul.ashraf\.local\bin\"
|
||||
|
||||
|
||||
Reference in new issue
Block a user