-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.ps1
43 lines (36 loc) · 1.43 KB
/
run.ps1
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
# run.ps1
# Function to stop all running processes for the project
function Stop-AllProcesses {
Write-Host "Stopping all processes..."
$processes = Get-Process | Where-Object { $_.Name -in @("python", "node") }
if ($processes) {
$processes | Stop-Process -Force
Write-Host "All processes stopped successfully."
} else {
Write-Host "No matching processes found to stop."
}
}
# Register a cleanup event to stop processes when the script exits
$script:ExitHandler = {
Stop-AllProcesses
}
Register-EngineEvent PowerShell.Exiting -Action $script:ExitHandler
# Helper function to run a process and keep the window open upon error or exit
function Start-ProcessWithWindow {
param (
[string]$Path,
[string]$Arguments,
[string]$WorkingDirectory
)
Start-Process -FilePath "powershell" -ArgumentList "-NoExit", "-Command", "cd '$WorkingDirectory'; $Path $Arguments"
}
# Start Python process
Write-Host "Starting SVM Model..."
Start-ProcessWithWindow -Path "python" -Arguments "svm_model.py" -WorkingDirectory "./backend/classifier"
# Start Node.js backend
Write-Host "Starting Backend Server..."
Start-ProcessWithWindow -Path "node" -Arguments "server.js" -WorkingDirectory "./backend"
# Start React frontend
Write-Host "Starting Frontend..."
Start-ProcessWithWindow -Path "npm" -Arguments "start" -WorkingDirectory "./frontend"
Write-Host "All processes have been started successfully!"