generated from kemboi22/laravel-inertia-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev-final.ps1
More file actions
172 lines (151 loc) Β· 6.45 KB
/
start-dev-final.ps1
File metadata and controls
172 lines (151 loc) Β· 6.45 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Graduate Tracking System - Development Server Starter
# PowerShell script for proper server startup sequence
Write-Host "========================================" -ForegroundColor Green
Write-Host " π Graduate Tracking System - Ready!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
# Kill any existing processes first
Write-Host "[0/5] Cleaning up existing processes..." -ForegroundColor Yellow
try {
Stop-Job -Name 'ViteServer' -ErrorAction SilentlyContinue
Remove-Job -Name 'ViteServer' -ErrorAction SilentlyContinue
Stop-Job -Name 'LaravelServer' -ErrorAction SilentlyContinue
Remove-Job -Name 'LaravelServer' -ErrorAction SilentlyContinue
taskkill /F /IM php.exe 2>$null | Out-Null
taskkill /F /IM node.exe 2>$null | Out-Null
Write-Host "β Existing processes cleaned up" -ForegroundColor Green
} catch {
Write-Host "β No existing processes to clean up" -ForegroundColor Green
}
# Check if PHP is available
Write-Host "[1/5] Checking PHP installation..." -ForegroundColor Yellow
try {
$phpVersion = & "D:\DevCenter\xampp\php-8.3.23\php.exe" --version 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "β PHP is available" -ForegroundColor Green
} else {
throw "PHP not found"
}
} catch {
Write-Host "β PHP not found at D:\DevCenter\xampp\php-8.3.23\php.exe" -ForegroundColor Red
exit 1
}
# Check if Node.js is available
Write-Host "[2/5] Checking Node.js installation..." -ForegroundColor Yellow
try {
$nodeVersion = node --version 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "β Node.js is available: $nodeVersion" -ForegroundColor Green
} else {
throw "Node.js not found"
}
} catch {
Write-Host "β Node.js not found. Please install Node.js" -ForegroundColor Red
exit 1
}
# Clear Laravel caches
Write-Host "[3/5] Clearing Laravel caches..." -ForegroundColor Yellow
try {
& "D:\DevCenter\xampp\php-8.3.23\php.exe" artisan config:clear 2>$null
& "D:\DevCenter\xampp\php-8.3.23\php.exe" artisan route:clear 2>$null
& "D:\DevCenter\xampp\php-8.3.23\php.exe" artisan view:clear 2>$null
& "D:\DevCenter\xampp\php-8.3.23\php.exe" artisan cache:clear 2>$null
Write-Host "β Laravel caches cleared" -ForegroundColor Green
} catch {
Write-Host "β οΈ Warning: Could not clear some caches" -ForegroundColor Yellow
}
# Start Vite development server
Write-Host "[4/5] Starting Vite development server..." -ForegroundColor Yellow
$viteJob = Start-Job -ScriptBlock {
Set-Location 'D:\DevCenter\abuilds\alumate'
npm run dev
} -Name 'ViteServer'
Write-Host "β Vite server starting..." -ForegroundColor Green
Start-Sleep -Seconds 10
# Start Laravel server
Write-Host "[5/5] Starting Laravel server..." -ForegroundColor Yellow
$laravelJob = Start-Job -ScriptBlock {
Set-Location 'D:\DevCenter\abuilds\alumate'
& 'D:\DevCenter\xampp\php-8.3.23\php.exe' artisan serve --host=127.0.0.1 --port=8080
} -Name 'LaravelServer'
Write-Host "β Laravel server starting..." -ForegroundColor Green
Start-Sleep -Seconds 8
# Check server status
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " π CHECKING SERVER STATUS" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
$viteRunning = $false
$laravelRunning = $false
# Check Vite
try {
$viteResponse = Invoke-WebRequest -Uri "http://localhost:5100" -TimeoutSec 5 -ErrorAction Stop
$viteRunning = $true
Write-Host "β
Vite Dev Server: http://localhost:5100" -ForegroundColor Green
} catch {
Write-Host "β οΈ Vite Dev Server: Starting..." -ForegroundColor Yellow
}
# Check Laravel
$attempts = 0
while (-not $laravelRunning -and $attempts -lt 5) {
try {
$laravelResponse = Invoke-WebRequest -Uri "http://127.0.0.1:8080" -TimeoutSec 10 -ErrorAction Stop
$laravelRunning = $true
Write-Host "β
Laravel Application: http://127.0.0.1:8080" -ForegroundColor Green
} catch {
$attempts++
Write-Host "β³ Attempt $attempts/5: Laravel starting..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " π SYSTEM READY!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "π DEMO ACCOUNTS:" -ForegroundColor Cyan
Write-Host " Super Admin:" -ForegroundColor Yellow
Write-Host " π§ admin@system.com" -ForegroundColor White
Write-Host " π password" -ForegroundColor White
Write-Host ""
Write-Host " Institution Admin:" -ForegroundColor Yellow
Write-Host " π§ admin@tech-institute.edu" -ForegroundColor White
Write-Host " π password" -ForegroundColor White
Write-Host ""
Write-Host " Graduate:" -ForegroundColor Yellow
Write-Host " π§ john.smith@student.edu" -ForegroundColor White
Write-Host " π password" -ForegroundColor White
Write-Host ""
Write-Host "π ACCESS LINKS:" -ForegroundColor Cyan
Write-Host " β’ Main App: http://127.0.0.1:8080" -ForegroundColor White
Write-Host " β’ Login: http://127.0.0.1:8080/login" -ForegroundColor White
Write-Host " β’ Register: http://127.0.0.1:8080/register" -ForegroundColor White
Write-Host ""
if ($laravelRunning) {
Write-Host "π Opening application..." -ForegroundColor Yellow
Start-Process "http://127.0.0.1:8080"
}
Write-Host "Press Ctrl+C to stop servers..." -ForegroundColor Yellow
Write-Host ""
# Monitor servers
try {
while ($true) {
$viteStatus = Get-Job -Name 'ViteServer' -ErrorAction SilentlyContinue
$laravelStatus = Get-Job -Name 'LaravelServer' -ErrorAction SilentlyContinue
if ($viteStatus.State -eq "Failed" -or $laravelStatus.State -eq "Failed") {
Write-Host "β οΈ Server stopped. Exiting..." -ForegroundColor Red
break
}
Start-Sleep -Seconds 10
}
} catch {
Write-Host "π Stopping servers..." -ForegroundColor Yellow
} finally {
Stop-Job -Name 'ViteServer' -ErrorAction SilentlyContinue
Remove-Job -Name 'ViteServer' -ErrorAction SilentlyContinue
Stop-Job -Name 'LaravelServer' -ErrorAction SilentlyContinue
Remove-Job -Name 'LaravelServer' -ErrorAction SilentlyContinue
taskkill /F /IM php.exe 2>$null | Out-Null
taskkill /F /IM node.exe 2>$null | Out-Null
Write-Host "β
All servers stopped!" -ForegroundColor Green
}