forked from existence-master/Sentient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_client_server.ps1
More file actions
52 lines (40 loc) · 1.92 KB
/
start_client_server.ps1
File metadata and controls
52 lines (40 loc) · 1.92 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
<#
.SYNOPSIS
Starts the frontend (Next.js) and backend (FastAPI) services for the Sentient project.
.DESCRIPTION
This script runs:
- The FastAPI backend server
- The Next.js frontend client
Both will be launched in separate PowerShell terminal windows with appropriate titles.
.NOTES
- Run this from your project's root directory.
#>
# --- Configuration ---
$projectRoot = $PSScriptRoot
if (-not $projectRoot) { $projectRoot = Get-Location }
$srcPath = Join-Path $projectRoot "src"
$clientPath = Join-Path $srcPath "client"
$venvActivatePath = Join-Path $srcPath "server\venv\Scripts\activate.ps1"
# --- Validation ---
if (-not (Test-Path $clientPath)) { throw "Frontend directory 'src/client' not found." }
if (-not (Test-Path $venvActivatePath)) { throw "Virtual environment activation script not found at '$venvActivatePath'." }
Write-Host "✅ Paths verified." -ForegroundColor Green
# --- Helper Function ---
function Start-NewTerminal {
param (
[string]$WindowTitle,
[string]$Command,
[string]$WorkDir = $projectRoot
)
$psCommand = "Set-Location -Path '$WorkDir'; `$Host.UI.RawUI.WindowTitle = '$WindowTitle'; $Command"
Start-Process powershell.exe -ArgumentList "-NoExit", "-Command", $psCommand -WorkingDirectory $WorkDir
}
# --- Start Backend ---
Write-Host "🚀 Launching FastAPI Backend..." -ForegroundColor Yellow
$backendCommand = "& '$venvActivatePath'; python -m server.main.app"
Start-NewTerminal -WindowTitle "API - Main Server" -Command $backendCommand -WorkDir $srcPath
# --- Start Frontend ---
Write-Host "🚀 Launching Next.js Frontend..." -ForegroundColor Yellow
Start-NewTerminal -WindowTitle "CLIENT - Next.js" -Command "npm run dev" -WorkDir $clientPath
Write-Host "`n✅ Frontend and backend launched successfully in new terminals." -ForegroundColh
Write-Host "`n✅ Frontend and backend launcoed successfully in new terminals." -ForegroundColor Greenr Green