forked from dividebysandwich/rustpos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.ps1
More file actions
45 lines (39 loc) · 1.02 KB
/
dev.ps1
File metadata and controls
45 lines (39 loc) · 1.02 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
# dev.ps1
$ErrorActionPreference = "Stop"
# Build the project
& .\build.ps1
# Change to rustpos directory
Set-Location rustpos
# Start rustpos in background
$rustposProcess = Start-Process -FilePath ".\rustpos.exe" -PassThru -NoNewWindow
# Cleanup function
function Cleanup {
Write-Host "Stopping development server..."
if ($rustposProcess -and !$rustposProcess.HasExited) {
try {
$rustposProcess.Kill()
$rustposProcess.WaitForExit(5000) # Wait up to 5 seconds
}
catch {
Write-Warning "Could not stop process gracefully"
}
}
exit
}
# Register cleanup for Ctrl+C
Register-EngineEvent PowerShell.Exiting -Action { Cleanup }
# Handle Ctrl+C
try {
Write-Host "Development server running. Press Ctrl+C to stop..."
# Wait for the process to exit or user interrupt
while (!$rustposProcess.HasExited) {
Start-Sleep -Milliseconds 100
}
}
catch {
# This will catch Ctrl+C and other interruptions
Cleanup
}
finally {
Cleanup
}