-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.ps1
More file actions
115 lines (102 loc) · 4.4 KB
/
stop.ps1
File metadata and controls
115 lines (102 loc) · 4.4 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
# Smart AI Trading Strategy Optimizer - Stop Script
# This script stops all services
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host "========================================" -ForegroundColor Red
Write-Host " Smart AI Trading Strategy Optimizer" -ForegroundColor Red
Write-Host " Stopping All Services" -ForegroundColor Red
Write-Host "========================================" -ForegroundColor Red
Write-Host ""
# ==========================================
# Step 1: Stop Node processes (Frontend)
# ==========================================
Write-Host "[1/5] Stopping Node processes (Frontend)..." -ForegroundColor Cyan
$nodeProcess = Get-Process -Name "node" -ErrorAction SilentlyContinue
if ($nodeProcess) {
$count = ($nodeProcess | Measure-Object).Count
Stop-Process -Name "node" -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
Write-Host " [OK] $count Node processes stopped" -ForegroundColor Green
} else {
Write-Host " [OK] No Node processes were running" -ForegroundColor Gray
}
Write-Host ""
# ==========================================
# Step 2: Stop Nginx processes (Frontend Web Server)
# ==========================================
Write-Host "[2/5] Stopping Nginx processes (Frontend Web Server)..." -ForegroundColor Cyan
$nginxProcess = Get-Process -Name "nginx" -ErrorAction SilentlyContinue
if ($nginxProcess) {
$count = ($nginxProcess | Measure-Object).Count
Stop-Process -Name "nginx" -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
Write-Host " [OK] $count Nginx processes stopped" -ForegroundColor Green
} else {
Write-Host " [OK] No Nginx processes were running" -ForegroundColor Gray
}
Write-Host ""
# ==========================================
# Step 3: Stop Django processes (Backend)
# ==========================================
Write-Host "[3/5] Stopping Django processes (Backend)..." -ForegroundColor Cyan
$djangoProcesses = Get-WmiObject Win32_Process | Where-Object { $_.CommandLine -like "*manage.py*runserver*" }
if ($djangoProcesses) {
$count = ($djangoProcesses | Measure-Object).Count
$djangoProcesses | ForEach-Object {
try {
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
} catch {}
}
Start-Sleep -Seconds 2
Write-Host " [OK] $count Django processes stopped" -ForegroundColor Green
} else {
Write-Host " [OK] No Django processes were running" -ForegroundColor Gray
}
Write-Host ""
# ==========================================
# Step 4: Stop Celery processes
# ==========================================
Write-Host "[4/5] Stopping Celery processes..." -ForegroundColor Cyan
$celeryProcesses = Get-WmiObject Win32_Process | Where-Object { $_.CommandLine -like "*celery*" }
if ($celeryProcesses) {
$count = ($celeryProcesses | Measure-Object).Count
$celeryProcesses | ForEach-Object {
try {
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
} catch {}
}
Start-Sleep -Seconds 2
Write-Host " [OK] $count Celery processes stopped" -ForegroundColor Green
} else {
Write-Host " [OK] No Celery processes were running" -ForegroundColor Gray
}
Write-Host ""
# ==========================================
# Step 5: Check Redis status
# ==========================================
Write-Host "[5/5] Checking Redis status..." -ForegroundColor Cyan
try {
$tcpClient = New-Object System.Net.Sockets.TcpClient
$tcpClient.Connect("localhost", 6379)
$tcpClient.Close()
Write-Host " [i] Redis is still running (Port 6379)" -ForegroundColor Yellow
Write-Host " Note: Redis is managed by Docker" -ForegroundColor Gray
Write-Host " To stop Redis: docker stop redis" -ForegroundColor Cyan
} catch {
Write-Host " [OK] Redis is not running" -ForegroundColor Gray
}
Write-Host ""
# ==========================================
# Final Summary
# ==========================================
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " [OK] All services stopped!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Note:" -ForegroundColor Yellow
Write-Host " - Redis is still running (if it was previously started)" -ForegroundColor White
Write-Host " - To stop Redis: docker stop redis" -ForegroundColor Cyan
Write-Host ""
Write-Host "Press Enter to exit..." -ForegroundColor Gray
Read-Host