Spaces:
Paused
Paused
| # WidgeTDC Development Startup Script | |
| # Kills existing processes before starting new ones | |
| $ErrorActionPreference = "SilentlyContinue" | |
| Write-Host "" | |
| Write-Host "========================================" -ForegroundColor Cyan | |
| Write-Host " WidgeTDC Development Startup" -ForegroundColor Cyan | |
| Write-Host "========================================" -ForegroundColor Cyan | |
| Write-Host "" | |
| # Check for existing processes on our ports | |
| $port3001 = Get-NetTCPConnection -LocalPort 3001 -State Listen 2>$null | |
| $port8080 = Get-NetTCPConnection -LocalPort 8080 -State Listen 2>$null | |
| if ($port3001 -or $port8080) { | |
| Write-Host "[WARNING] Existing processes detected!" -ForegroundColor Yellow | |
| if ($port3001) { | |
| $pid3001 = $port3001.OwningProcess | |
| Write-Host " - Port 3001 (Backend): PID $pid3001" -ForegroundColor Yellow | |
| } | |
| if ($port8080) { | |
| $pid8080 = $port8080.OwningProcess | |
| Write-Host " - Port 8080 (Frontend): PID $pid8080" -ForegroundColor Yellow | |
| } | |
| Write-Host "" | |
| Write-Host "Killing existing processes in 3 seconds..." -ForegroundColor Yellow | |
| Write-Host "(Press Ctrl+C to cancel)" -ForegroundColor DarkGray | |
| Start-Sleep -Seconds 3 | |
| if ($port3001) { | |
| Write-Host " Killing PID $pid3001 (port 3001)..." -ForegroundColor Red | |
| Stop-Process -Id $pid3001 -Force 2>$null | |
| } | |
| if ($port8080) { | |
| Write-Host " Killing PID $pid8080 (port 8080)..." -ForegroundColor Red | |
| Stop-Process -Id $pid8080 -Force 2>$null | |
| } | |
| Start-Sleep -Seconds 1 | |
| Write-Host " Done!" -ForegroundColor Green | |
| Write-Host "" | |
| } | |
| # Also kill any node processes running our specific files | |
| $nodeProcesses = Get-Process -Name "node" 2>$null | Where-Object { | |
| $_.CommandLine -like "*tsx*" -or $_.CommandLine -like "*vite*" | |
| } | |
| if ($nodeProcesses) { | |
| Write-Host "[INFO] Found orphan node processes, cleaning up..." -ForegroundColor Yellow | |
| $nodeProcesses | ForEach-Object { | |
| Write-Host " Killing PID $($_.Id)..." -ForegroundColor DarkGray | |
| Stop-Process -Id $_.Id -Force 2>$null | |
| } | |
| Start-Sleep -Seconds 1 | |
| } | |
| Write-Host "" | |
| Write-Host "Starting services..." -ForegroundColor Green | |
| Write-Host "" | |
| # Start Backend | |
| Write-Host "[1/2] Starting Backend (port 3001)..." -ForegroundColor Cyan | |
| $backendJob = Start-Job -ScriptBlock { | |
| Set-Location $using:PWD | |
| Set-Location apps/backend | |
| npm run dev 2>&1 | |
| } | |
| Start-Sleep -Seconds 2 | |
| # Start Frontend | |
| Write-Host "[2/2] Starting Frontend (port 8080)..." -ForegroundColor Cyan | |
| $frontendJob = Start-Job -ScriptBlock { | |
| Set-Location $using:PWD | |
| Set-Location apps/matrix-frontend | |
| npm run dev 2>&1 | |
| } | |
| Write-Host "" | |
| Write-Host "========================================" -ForegroundColor Green | |
| Write-Host " Services Starting!" -ForegroundColor Green | |
| Write-Host "========================================" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host " Frontend: http://localhost:8080" -ForegroundColor White | |
| Write-Host " Backend: http://localhost:3001" -ForegroundColor White | |
| Write-Host " Health: http://localhost:3001/health" -ForegroundColor DarkGray | |
| Write-Host "" | |
| Write-Host "Press Ctrl+C to stop all services" -ForegroundColor DarkGray | |
| Write-Host "" | |
| # Wait and show output | |
| try { | |
| while ($true) { | |
| # Check if jobs are still running | |
| $backendState = (Get-Job -Id $backendJob.Id).State | |
| $frontendState = (Get-Job -Id $frontendJob.Id).State | |
| # Get and display any new output | |
| Receive-Job -Job $backendJob -ErrorAction SilentlyContinue | ForEach-Object { | |
| Write-Host "[BACKEND] $_" -ForegroundColor DarkCyan | |
| } | |
| Receive-Job -Job $frontendJob -ErrorAction SilentlyContinue | ForEach-Object { | |
| Write-Host "[FRONTEND] $_" -ForegroundColor DarkMagenta | |
| } | |
| Start-Sleep -Milliseconds 500 | |
| } | |
| } | |
| finally { | |
| Write-Host "" | |
| Write-Host "Stopping services..." -ForegroundColor Yellow | |
| Stop-Job -Job $backendJob 2>$null | |
| Stop-Job -Job $frontendJob 2>$null | |
| Remove-Job -Job $backendJob 2>$null | |
| Remove-Job -Job $frontendJob 2>$null | |
| # Kill any remaining processes on our ports | |
| $port3001 = Get-NetTCPConnection -LocalPort 3001 -State Listen 2>$null | |
| $port8080 = Get-NetTCPConnection -LocalPort 8080 -State Listen 2>$null | |
| if ($port3001) { Stop-Process -Id $port3001.OwningProcess -Force 2>$null } | |
| if ($port8080) { Stop-Process -Id $port8080.OwningProcess -Force 2>$null } | |
| Write-Host "Goodbye!" -ForegroundColor Green | |
| } | |