#Requires -Version 5.1 <# .SYNOPSIS Startet die NexusRMM Entwicklungsumgebung .DESCRIPTION Startet Docker (Postgres), fuehrt DB-Migrationen aus, startet Backend und Frontend in separaten Fenstern. #> $ErrorActionPreference = "Continue" $Root = "D:\001_Projekte\IT_Tool" function Write-Step { param($msg) Write-Host "" ; Write-Host "==> $msg" -ForegroundColor Cyan } function Write-OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green } function Write-Warn { param($msg) Write-Host " [!] $msg" -ForegroundColor Yellow } function Write-Fail { param($msg) Write-Host " [FEHLER] $msg" -ForegroundColor Red } # --------------------------------------------------------------------------- # 1. Voraussetzungen pruefen # --------------------------------------------------------------------------- Write-Step "Pruefe Voraussetzungen..." $missing = $false $tools = @( @{ Name = "docker"; Desc = "Docker Desktop" }, @{ Name = "dotnet"; Desc = ".NET SDK" }, @{ Name = "node"; Desc = "Node.js" }, @{ Name = "npm"; Desc = "npm" } ) foreach ($tool in $tools) { $cmd = Get-Command $tool.Name -ErrorAction SilentlyContinue if ($null -eq $cmd) { Write-Fail "$($tool.Desc) ($($tool.Name)) nicht gefunden." $missing = $true } else { Write-OK "$($tool.Desc): gefunden" } } if ($missing) { Write-Fail "Fehlende Voraussetzungen. Bitte installieren und erneut starten." exit 1 } # dotnet-ef pruefen $efCheck = dotnet tool list --global 2>$null | Select-String "dotnet-ef" if (-not $efCheck) { Write-Warn "dotnet-ef nicht gefunden. Installiere..." dotnet tool install --global dotnet-ef if ($LASTEXITCODE -ne 0) { Write-Fail "dotnet-ef konnte nicht installiert werden." exit 1 } Write-OK "dotnet-ef installiert." } else { Write-OK "dotnet-ef: vorhanden" } # --------------------------------------------------------------------------- # 2. PostgreSQL per Docker starten # --------------------------------------------------------------------------- Write-Step "Starte PostgreSQL..." Set-Location $Root docker compose up -d nexusrmm-postgres if ($LASTEXITCODE -ne 0) { Write-Fail "docker compose up fehlgeschlagen. Laeuft Docker Desktop?" exit 1 } Write-Host " Warte auf PostgreSQL..." -ForegroundColor Cyan $maxWait = 30 $waited = 0 $pgReady = $false while ($waited -lt $maxWait) { docker exec nexusrmm-postgres pg_isready -U nexusrmm -q 2>$null if ($LASTEXITCODE -eq 0) { $pgReady = $true break } Start-Sleep -Seconds 2 $waited += 2 } if (-not $pgReady) { Write-Fail "PostgreSQL ist nach $maxWait Sekunden nicht erreichbar." exit 1 } Write-OK "PostgreSQL bereit (Port 5433)." # --------------------------------------------------------------------------- # 3. EF Core Migrationen # --------------------------------------------------------------------------- Write-Step "Fuehre Datenbank-Migrationen aus..." Set-Location "$Root\Backend" dotnet ef database update --project "src\NexusRMM.Infrastructure" --startup-project "src\NexusRMM.Api" --no-build 2>&1 | Out-Default if ($LASTEXITCODE -ne 0) { Write-Warn "Migration mit --no-build fehlgeschlagen. Baue zuerst..." dotnet build "src\NexusRMM.Api" --configuration Debug -q if ($LASTEXITCODE -ne 0) { Write-Fail "dotnet build fehlgeschlagen." Set-Location $Root exit 1 } dotnet ef database update --project "src\NexusRMM.Infrastructure" --startup-project "src\NexusRMM.Api" if ($LASTEXITCODE -ne 0) { Write-Fail "dotnet ef database update fehlgeschlagen." Set-Location $Root exit 1 } } Set-Location $Root Write-OK "Migrationen erfolgreich." # --------------------------------------------------------------------------- # 4. Backend in neuem PowerShell-Fenster starten # --------------------------------------------------------------------------- Write-Step "Starte Backend..." $backendCmd = "Set-Location '$Root\Backend'; Write-Host 'NexusRMM Backend gestartet' -ForegroundColor Cyan; dotnet run --project src/NexusRMM.Api" Start-Process powershell -ArgumentList "-NoExit", "-Command", $backendCmd -WindowStyle Normal Write-OK "Backend-Fenster geoeffnet." # --------------------------------------------------------------------------- # 5. Kurz warten # --------------------------------------------------------------------------- Write-Host " Warte 5 Sekunden fuer Backend-Start..." -ForegroundColor Cyan Start-Sleep -Seconds 5 # --------------------------------------------------------------------------- # 6. Frontend in neuem PowerShell-Fenster starten # --------------------------------------------------------------------------- Write-Step "Starte Frontend..." $frontendCmd = "Set-Location '$Root\Frontend'; Write-Host 'NexusRMM Frontend gestartet' -ForegroundColor Cyan; npm run dev" Start-Process powershell -ArgumentList "-NoExit", "-Command", $frontendCmd -WindowStyle Normal Write-OK "Frontend-Fenster geoeffnet." # --------------------------------------------------------------------------- # 7. Zusammenfassung # --------------------------------------------------------------------------- Write-Host "" Write-Host "+------------------------------------------+" -ForegroundColor Green Write-Host "| NexusRMM ist bereit! |" -ForegroundColor Green Write-Host "+------------------------------------------+" -ForegroundColor Green Write-Host "| Frontend: http://localhost:5173 |" -ForegroundColor Green Write-Host "| Backend: http://localhost:5000 |" -ForegroundColor Green Write-Host "| Swagger: http://localhost:5000/swagger |" -ForegroundColor Green Write-Host "| gRPC: http://localhost:5001 |" -ForegroundColor Green Write-Host "| MeshCentral: https://localhost:4430 |" -ForegroundColor Green Write-Host "+------------------------------------------+" -ForegroundColor Green Write-Host "" Write-Host "Agent starten: .\Agent\nexus-agent.exe" -ForegroundColor Yellow Write-Host "Alles stoppen: .\dev-stop.ps1" -ForegroundColor Yellow Write-Host ""