-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all.ps1
More file actions
58 lines (46 loc) · 1.79 KB
/
run-all.ps1
File metadata and controls
58 lines (46 loc) · 1.79 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
#Requires -Version 5.1
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$BackendDir = Join-Path $ScriptDir "petclinic-backend"
$FrontendDir = Join-Path $ScriptDir "petclinic-frontend"
$BackendProcess = $null
$FrontendProcess = $null
function Stop-Services {
Write-Host "Stopping backend and frontend..."
if ($null -ne $BackendProcess -and -not $BackendProcess.HasExited) {
taskkill /T /F /PID $BackendProcess.Id 2>$null | Out-Null
}
if ($null -ne $FrontendProcess -and -not $FrontendProcess.HasExited) {
taskkill /T /F /PID $FrontendProcess.Id 2>$null | Out-Null
}
}
if (-not (Test-Path $BackendDir)) {
Write-Error "Backend directory not found: $BackendDir"
exit 1
}
if (-not (Test-Path $FrontendDir)) {
Write-Error "Frontend directory not found: $FrontendDir"
exit 1
}
try {
Write-Host "Starting Petclinic Backend (Spring Boot)..."
$BackendProcess = Start-Process -FilePath "cmd.exe" `
-ArgumentList "/c cd /d `"$BackendDir`" && mvnw.cmd spring-boot:run" `
-PassThru -NoNewWindow
Write-Host "Starting Petclinic Frontend (Angular)..."
$FrontendProcess = Start-Process -FilePath "cmd.exe" `
-ArgumentList "/c cd /d `"$FrontendDir`" && npm start" `
-PassThru -NoNewWindow
Write-Host "Backend PID: $($BackendProcess.Id)"
Write-Host "Frontend PID: $($FrontendProcess.Id)"
Write-Host "Both services are starting. Press Ctrl+C to stop both."
Write-Host "Frontend: http://localhost:4200/"
Write-Host "Backend: http://localhost:8080/"
# Keep running until one process exits or Ctrl+C is pressed
while (-not $BackendProcess.HasExited -and -not $FrontendProcess.HasExited) {
Start-Sleep -Milliseconds 500
}
}
finally {
Stop-Services
}