-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathstop_servers.ps1
More file actions
77 lines (67 loc) · 2.67 KB
/
stop_servers.ps1
File metadata and controls
77 lines (67 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# Code Hacker — Server Management (Windows PowerShell)
#
# Usage:
# .\stop_servers.ps1 # Stop all MCP servers
# .\stop_servers.ps1 -Status # Check server status
#
param(
[switch]$Status
)
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$PidDir = Join-Path $ScriptDir ".mcp_pids"
$Servers = @(
@{ Script = "filesystem.py"; Port = 8001; Name = "filesystem-command" },
@{ Script = "git_tools.py"; Port = 8002; Name = "git-tools" },
@{ Script = "code_intel.py"; Port = 8003; Name = "code-intel" },
@{ Script = "memory_store.py"; Port = 8004; Name = "memory-store" },
@{ Script = "code_review.py"; Port = 8005; Name = "code-review" },
@{ Script = "multi_project.py"; Port = 8007; Name = "multi-project" }
)
if ($Status) {
Write-Host "=== MCP Server Status ===" -ForegroundColor Cyan
Write-Host ""
foreach ($srv in $Servers) {
$sname = $srv.Script -replace '\.py$', ''
$pidFile = Join-Path $PidDir "$sname.pid"
$running = $false
if (Test-Path $pidFile) {
$pid = Get-Content $pidFile -ErrorAction SilentlyContinue
try {
$proc = Get-Process -Id $pid -ErrorAction SilentlyContinue
if ($proc -and -not $proc.HasExited) { $running = $true }
} catch {}
}
if ($running) {
Write-Host " [UP] $($srv.Name) - port $($srv.Port) - PID $pid" -ForegroundColor Green
} else {
Write-Host " [DOWN] $($srv.Name) - port $($srv.Port)" -ForegroundColor Red
}
}
} else {
Write-Host "=== Stopping MCP Servers ===" -ForegroundColor Cyan
Write-Host ""
foreach ($srv in $Servers) {
$sname = $srv.Script -replace '\.py$', ''
$pidFile = Join-Path $PidDir "$sname.pid"
if (Test-Path $pidFile) {
$pid = Get-Content $pidFile -ErrorAction SilentlyContinue
try {
$proc = Get-Process -Id $pid -ErrorAction SilentlyContinue
if ($proc -and -not $proc.HasExited) {
Stop-Process -Id $pid -Force
Write-Host " [STOP] $($srv.Name) (PID $pid)" -ForegroundColor Yellow
} else {
Write-Host " [SKIP] $($srv.Name) - not running" -ForegroundColor Gray
}
} catch {
Write-Host " [SKIP] $($srv.Name) - not running" -ForegroundColor Gray
}
Remove-Item $pidFile -Force -ErrorAction SilentlyContinue
} else {
Write-Host " [SKIP] $($srv.Name) - no PID file" -ForegroundColor Gray
}
}
Write-Host ""
Write-Host "All servers stopped." -ForegroundColor Green
}