-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.ps1
More file actions
66 lines (58 loc) · 2.21 KB
/
start.ps1
File metadata and controls
66 lines (58 loc) · 2.21 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
# ResearchOS - start backend + frontend in one command
# Usage: .\start.ps1
Write-Host "Starting ResearchOS..." -ForegroundColor Cyan
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# Kill anything already using our ports
foreach ($port in @(8000, 3000)) {
$connections = netstat -ano | Select-String ":$port\s" | Select-String "LISTENING"
foreach ($conn in $connections) {
$pid = ($conn -split '\s+')[-1]
if ($pid -match '^\d+$') {
Write-Host " Killing existing process on port $port (PID $pid)" -ForegroundColor Yellow
Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue
}
}
}
# Wait for ports to be released
Start-Sleep -Seconds 2
# Start Backend
Write-Host " Starting backend (FastAPI) on http://localhost:8000 ..." -ForegroundColor Green
$backendJob = Start-Job -ScriptBlock {
param($dir)
Set-Location "$dir\backend"
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
} -ArgumentList $scriptDir
# Start Frontend
Write-Host " Starting frontend (Next.js) on http://localhost:3000 ..." -ForegroundColor Green
$frontendJob = Start-Job -ScriptBlock {
param($dir)
Set-Location "$dir\frontend"
npm run dev
} -ArgumentList $scriptDir
Write-Host ""
Write-Host "ResearchOS is running!" -ForegroundColor Green
Write-Host " Frontend: http://localhost:3000"
Write-Host " Backend: http://localhost:8000"
Write-Host " API docs: http://localhost:8000/docs"
Write-Host ""
Write-Host "Press Ctrl+C to stop." -ForegroundColor Cyan
# Wait for user to press Ctrl+C
try {
while ($true) {
Start-Sleep -Seconds 1
# Check if jobs are still running
if ($backendJob.State -eq "Failed" -or $frontendJob.State -eq "Failed") {
Write-Host "A process has failed. Check the output above." -ForegroundColor Red
break
}
}
}
finally {
Write-Host ""
Write-Host "Shutting down..." -ForegroundColor Yellow
Stop-Job $backendJob -ErrorAction SilentlyContinue
Stop-Job $frontendJob -ErrorAction SilentlyContinue
Remove-Job $backendJob -ErrorAction SilentlyContinue
Remove-Job $frontendJob -ErrorAction SilentlyContinue
Write-Host " Done." -ForegroundColor Green
}