-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-server.ps1
More file actions
48 lines (39 loc) · 1.82 KB
/
run-server.ps1
File metadata and controls
48 lines (39 loc) · 1.82 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
# Restart SharpGraph Server
Write-Host "Restarting SharpGraph Server..." -ForegroundColor Cyan
# Kill any existing server processes
Get-Process | Where-Object { $_.ProcessName -like "*SharpGraph.Server*" } | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 1
# Start server in new window
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$scriptPath'; Write-Host 'Building and starting server...' -ForegroundColor Yellow; dotnet run --project src\SharpGraph.Server --configuration Release"
Write-Host "Server starting in new window!" -ForegroundColor Green
Write-Host "Waiting for server to be ready..." -ForegroundColor Yellow
# Wait for server to be ready
$ready = $false
$attempts = 0
$maxAttempts = 15
while (-not $ready -and $attempts -lt $maxAttempts) {
Start-Sleep -Seconds 1
$attempts++
try {
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8080/graphql?sdl' -Method GET -TimeoutSec 2 -ErrorAction SilentlyContinue
if ($response.StatusCode -eq 200) {
$ready = $true
}
} catch {
Write-Host "." -NoNewline -ForegroundColor Gray
}
}
if ($ready) {
Write-Host ""
Write-Host "Server is ready at http://127.0.0.1:8080/graphql" -ForegroundColor Green
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Server is running!" -ForegroundColor Green
Write-Host "Check SERVER_GUIDE.md for more examples" -ForegroundColor Yellow
Write-Host "Server window is open - close it to stop" -ForegroundColor Yellow
} else {
Write-Host ""
Write-Host "Server failed to start within $maxAttempts seconds" -ForegroundColor Red
Write-Host "Check the server window for errors" -ForegroundColor Yellow
}