Spaces:
Paused
Paused
File size: 3,791 Bytes
5a81b95 | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | # WidgeTDC Development Startup Script
# Robust startup med health checks
param(
[switch]$SkipDocker,
[switch]$BackendOnly,
[switch]$FrontendOnly
)
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host " WidgeTDC Development Environment Startup" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
# Function til at tjekke om en port er i brug
function Test-Port {
param([int]$Port)
$connection = New-Object System.Net.Sockets.TcpClient
try {
$connection.Connect("localhost", $Port)
$connection.Close()
return $true
} catch {
return $false
}
}
# Function til at vente på service
function Wait-ForService {
param(
[string]$Name,
[int]$Port,
[int]$MaxAttempts = 30
)
Write-Host " Waiting for $Name on port $Port..." -NoNewline
for ($i = 1; $i -le $MaxAttempts; $i++) {
if (Test-Port -Port $Port) {
Write-Host " OK" -ForegroundColor Green
return $true
}
Start-Sleep -Seconds 1
Write-Host "." -NoNewline
}
Write-Host " TIMEOUT" -ForegroundColor Red
return $false
}
# Step 1: Start Docker services
if (-not $SkipDocker) {
Write-Host "[1/4] Starting Docker infrastructure..." -ForegroundColor Yellow
# Check if docker is running
$dockerRunning = docker info 2>&1 | Select-String "Server Version"
if (-not $dockerRunning) {
Write-Host " ERROR: Docker is not running. Please start Docker Desktop." -ForegroundColor Red
exit 1
}
# Start services
docker-compose up -d
# Wait for services
Write-Host ""
Write-Host " Waiting for services to be healthy..." -ForegroundColor Gray
$pgReady = Wait-ForService -Name "PostgreSQL" -Port 5432 -MaxAttempts 30
$redisReady = Wait-ForService -Name "Redis" -Port 6379 -MaxAttempts 20
$neo4jReady = Wait-ForService -Name "Neo4j" -Port 7687 -MaxAttempts 45
if (-not ($pgReady -and $redisReady)) {
Write-Host ""
Write-Host " WARNING: Some services failed to start. Backend may have limited functionality." -ForegroundColor Yellow
}
Write-Host ""
} else {
Write-Host "[1/4] Skipping Docker (--SkipDocker)" -ForegroundColor Gray
}
# Step 2: Install dependencies if needed
Write-Host "[2/4] Checking dependencies..." -ForegroundColor Yellow
if (-not (Test-Path "node_modules")) {
Write-Host " Running npm install..." -ForegroundColor Gray
npm install
}
Write-Host " Dependencies OK" -ForegroundColor Green
Write-Host ""
# Step 3: Build shared packages
Write-Host "[3/4] Building shared packages..." -ForegroundColor Yellow
npm run build:shared 2>&1 | Out-Null
Write-Host " Shared packages built" -ForegroundColor Green
Write-Host ""
# Step 4: Start applications
Write-Host "[4/4] Starting applications..." -ForegroundColor Yellow
if ($BackendOnly) {
Write-Host " Starting backend only..." -ForegroundColor Gray
npm run dev:backend
} elseif ($FrontendOnly) {
Write-Host " Starting frontend only..." -ForegroundColor Gray
npm run dev:frontend
} else {
Write-Host " Starting backend and frontend concurrently..." -ForegroundColor Gray
Write-Host ""
Write-Host "================================================" -ForegroundColor Green
Write-Host " Backend: http://localhost:3001" -ForegroundColor White
Write-Host " Frontend: http://localhost:5173" -ForegroundColor White
Write-Host " Neo4j: http://localhost:7474" -ForegroundColor White
Write-Host "================================================" -ForegroundColor Green
Write-Host ""
npm run dev
}
|