-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-all.ps1
More file actions
149 lines (132 loc) · 5.46 KB
/
stop-all.ps1
File metadata and controls
149 lines (132 loc) · 5.46 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Stop all SteerDock services
.DESCRIPTION
Stops all running SteerDock services (backend, frontend, desktop app)
.PARAMETER Force
Force kill processes without graceful shutdown
.EXAMPLE
.\stop-all.ps1
.\stop-all.ps1 -Force
#>
param(
[switch]$Force
)
$ErrorActionPreference = "Stop"
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Red
Write-Host "║ Stopping All SteerDock Services ║" -ForegroundColor Red
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Red
Write-Host ""
$stoppedCount = 0
# Stop desktop application
Write-Host "Stopping desktop application..." -ForegroundColor Yellow
$desktopProcs = Get-Process -Name "SteerDock-frontend" -ErrorAction SilentlyContinue
if ($desktopProcs) {
$desktopProcs | ForEach-Object {
Write-Host " Stopping SteerDock-frontend.exe (PID: $($_.Id))" -ForegroundColor Gray
if ($Force) {
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
} else {
Stop-Process -Id $_.Id -ErrorAction SilentlyContinue
}
$stoppedCount++
}
Write-Host " Desktop app stopped" -ForegroundColor Green
} else {
Write-Host " Desktop app not running" -ForegroundColor Gray
}
Write-Host ""
# Stop frontend dev server (Node/Vite)
Write-Host "Stopping frontend dev server..." -ForegroundColor Yellow
$nodeProcs = Get-Process -Name "node" -ErrorAction SilentlyContinue | Where-Object {
$_.CommandLine -like "*vite*" -or $_.CommandLine -like "*npm*dev*"
}
if ($nodeProcs) {
$nodeProcs | ForEach-Object {
Write-Host " Stopping Node.js/Vite (PID: $($_.Id))" -ForegroundColor Gray
if ($Force) {
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
} else {
Stop-Process -Id $_.Id -ErrorAction SilentlyContinue
}
$stoppedCount++
}
Write-Host " Frontend dev server stopped" -ForegroundColor Green
} else {
Write-Host " Frontend dev server not running" -ForegroundColor Gray
}
Write-Host ""
# Stop backend services (compiled binaries)
Write-Host "Stopping backend services..." -ForegroundColor Yellow
$backendServices = @("steerdock")
foreach ($svcName in $backendServices) {
$procs = Get-Process -Name $svcName -ErrorAction SilentlyContinue
if ($procs) {
$procs | ForEach-Object {
Write-Host " Stopping $svcName (PID: $($_.Id))" -ForegroundColor Gray
if ($Force) {
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
} else {
Stop-Process -Id $_.Id -ErrorAction SilentlyContinue
}
$stoppedCount++
}
}
}
# Stop Go development processes (go run)
$goProcs = Get-Process -Name "go" -ErrorAction SilentlyContinue
if ($goProcs) {
$goProcs | ForEach-Object {
Write-Host " Stopping go process (PID: $($_.Id))" -ForegroundColor Gray
if ($Force) {
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
} else {
Stop-Process -Id $_.Id -ErrorAction SilentlyContinue
}
$stoppedCount++
}
}
if ($stoppedCount -gt 0) {
Write-Host " Backend services stopped" -ForegroundColor Green
} else {
Write-Host " No backend services running" -ForegroundColor Gray
}
Write-Host ""
# Wait for processes to fully terminate
Start-Sleep -Seconds 2
# Check for lingering processes on ports
Write-Host "Checking for processes on SteerDock ports..." -ForegroundColor Yellow
$ports = @(8383, 5151)
$lingering = $false
foreach ($port in $ports) {
$conn = Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue
if ($conn) {
$procId = $conn.OwningProcess
$proc = Get-Process -Id $procId -ErrorAction SilentlyContinue
if ($proc) {
Write-Host " Port $port still in use by: $($proc.Name) (PID: $procId)" -ForegroundColor Red
$lingering = $true
if ($Force) {
Write-Host " Force stopping process..." -ForegroundColor Yellow
Stop-Process -Id $procId -Force -ErrorAction SilentlyContinue
}
}
}
}
if (-not $lingering) {
Write-Host " All ports are free" -ForegroundColor Green
}
Write-Host ""
# Summary
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Green
Write-Host "║ All Services Stopped ║" -ForegroundColor Green
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Green
Write-Host ""
Write-Host " Summary:" -ForegroundColor Cyan
Write-Host " Stopped processes: $stoppedCount" -ForegroundColor Gray
Write-Host ""
if ($lingering -and -not $Force) {
Write-Host " Tip: Use -Force flag to forcefully kill lingering processes" -ForegroundColor Yellow
Write-Host " .\stop-all.ps1 -Force" -ForegroundColor Gray
}