Spaces:
Runtime error
Runtime error
| # Contravault Full Stack Startup Script | |
| # Run with: .\start.ps1 | |
| Write-Host "============================================" -ForegroundColor Cyan | |
| Write-Host " CONTRAVAULT - Starting All Services" -ForegroundColor Cyan | |
| Write-Host "============================================" -ForegroundColor Cyan | |
| Write-Host "" | |
| # Kill any existing processes on ports 3000 and 8000 | |
| Write-Host "Checking for existing processes..." -ForegroundColor Yellow | |
| $port8000 = Get-NetTCPConnection -LocalPort 8000 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | |
| $port3000 = Get-NetTCPConnection -LocalPort 3000 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | |
| if ($port8000) { | |
| Write-Host " Stopping existing backend on port 8000..." -ForegroundColor Yellow | |
| Stop-Process -Id $port8000 -Force -ErrorAction SilentlyContinue | |
| } | |
| if ($port3000) { | |
| Write-Host " Stopping existing frontend on port 3000..." -ForegroundColor Yellow | |
| Stop-Process -Id $port3000 -Force -ErrorAction SilentlyContinue | |
| } | |
| Start-Sleep -Seconds 2 | |
| # Start Backend | |
| Write-Host "" | |
| Write-Host "[1/2] Starting Backend Server (FastAPI on port 8000)..." -ForegroundColor Blue | |
| $backendJob = Start-Process -FilePath "cmd" -ArgumentList "/k", "cd /d `"$PSScriptRoot\backend`" && .\venv\Scripts\activate && python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000" -PassThru | |
| Start-Sleep -Seconds 3 | |
| # Start Frontend | |
| Write-Host "[2/2] Starting Frontend Server (Next.js on port 3000)..." -ForegroundColor Green | |
| $frontendJob = Start-Process -FilePath "cmd" -ArgumentList "/k", "cd /d `"$PSScriptRoot`" && npm run frontend" -PassThru | |
| Write-Host "" | |
| Write-Host "============================================" -ForegroundColor Cyan | |
| Write-Host " Both servers are starting!" -ForegroundColor Cyan | |
| Write-Host "============================================" -ForegroundColor Cyan | |
| Write-Host "" | |
| Write-Host " Backend: " -NoNewline; Write-Host "http://localhost:8000" -ForegroundColor Yellow | |
| Write-Host " Frontend: " -NoNewline; Write-Host "http://localhost:3000" -ForegroundColor Yellow | |
| Write-Host " API Docs: " -NoNewline; Write-Host "http://localhost:8000/docs" -ForegroundColor Yellow | |
| Write-Host "" | |
| # Wait and open browser | |
| Start-Sleep -Seconds 5 | |
| Write-Host "Opening browser..." -ForegroundColor Green | |
| Start-Process "http://localhost:3000" | |
| Write-Host "" | |
| Write-Host "Press Enter to stop all servers..." -ForegroundColor Red | |
| Read-Host | |
| # Cleanup | |
| Write-Host "Stopping servers..." -ForegroundColor Yellow | |
| Stop-Process -Id $backendJob.Id -Force -ErrorAction SilentlyContinue | |
| Stop-Process -Id $frontendJob.Id -Force -ErrorAction SilentlyContinue | |
| # Also kill any remaining processes on the ports | |
| $port8000 = Get-NetTCPConnection -LocalPort 8000 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | |
| $port3000 = Get-NetTCPConnection -LocalPort 3000 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | |
| if ($port8000) { Stop-Process -Id $port8000 -Force -ErrorAction SilentlyContinue } | |
| if ($port3000) { Stop-Process -Id $port3000 -Force -ErrorAction SilentlyContinue } | |
| Write-Host "Done!" -ForegroundColor Green | |