File size: 2,099 Bytes
8085285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c4c8a0
8085285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ============================================================
#  AI API Testing Tool - Dev Startup Script
#  Usage: .\start.ps1
# ============================================================

$ErrorActionPreference = "Stop"

Write-Host ""
Write-Host "  AI API Testing Tool" -ForegroundColor Cyan
Write-Host "  ===================" -ForegroundColor Cyan
Write-Host ""

# --- 1. Kill any stale process on port 8001 ---
# --- 1. Kill any stale process on port 8001 ---
Write-Host "[1/3] Checking for processes on port 8001..." -ForegroundColor Yellow
$stale = netstat -aon | Select-String ":8001 " | Select-String "LISTENING"
if ($stale) {
    $pid_ = ($stale -split "\s+")[-1]
    Write-Host "      Killing stale process (PID $pid_)..." -ForegroundColor DarkYellow
    Stop-Process -Id $pid_ -Force -ErrorAction SilentlyContinue
    Start-Sleep -Seconds 2
} else {
    Write-Host "      Port 8001 is free." -ForegroundColor Green
}

# --- 2. Start FastAPI Backend ---
Write-Host "[2/3] Starting FastAPI backend (port 8001)..." -ForegroundColor Yellow
$backend = Start-Process -FilePath "cmd.exe" `
    -ArgumentList "/k", "title Backend && python -m uvicorn backend.main:app --reload --port 8001 --log-level info" `
    -WorkingDirectory $PSScriptRoot `
    -PassThru

Write-Host "      Backend PID: $($backend.Id)" -ForegroundColor Green
Write-Host "      Waiting 8s for backend to initialize..." -ForegroundColor DarkGray
Start-Sleep -Seconds 8

# --- 3. Start React Frontend ---
Write-Host "[3/3] Starting React frontend (Vite dev server)..." -ForegroundColor Yellow
Start-Process -FilePath "cmd.exe" `
    -ArgumentList "/k", "title Frontend && npm run dev" `
    -WorkingDirectory (Join-Path $PSScriptRoot "frontend-react")

Write-Host ""
Write-Host "  All services started!" -ForegroundColor Green
Write-Host ""
Write-Host "  Backend  -> http://localhost:8001" -ForegroundColor Cyan
Write-Host "  Frontend -> http://localhost:5173" -ForegroundColor Cyan
Write-Host "  API Docs -> http://localhost:8001/docs" -ForegroundColor Cyan
Write-Host ""