<# .SYNOPSIS Startet GerbilManager im Produktionsmodus (API + Datenbank + Frontend). .DESCRIPTION Setzt die Produktionsumgebung, legt Datenverzeichnisse an und startet den Aspire AppHost im Hintergrund. Der Prozess laeuft als minimiertes Fenster. Der Pfad zum AppHost wird relativ zu diesem Skript aufgeloest. .NOTES Erfordert: .NET SDK 10+, Docker Desktop (running), Node.js 18+ Startet auf: http://:5173 (Frontend), http://:5179 (API) #> param( [switch]$Wait # Blockiert bis Ctrl+C wenn gesetzt (fuer manuelle Starts) ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $projectRoot = Resolve-Path (Join-Path $PSScriptRoot "..\..") # --- Datenverzeichnisse sicherstellen --- $dataRoot = "C:\gerbil-data" $photosDir = "$dataRoot\photos" $backupsDir = "$dataRoot\backups" foreach ($dir in @($photosDir, $backupsDir)) { if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null Write-Host "Verzeichnis angelegt: $dir" } } # --- Produktionsumgebung setzen --- $env:ASPNETCORE_ENVIRONMENT = "Production" $env:DOTNET_ENVIRONMENT = "Production" # Aspire Dashboard-Browser nicht automatisch oeffnen $env:DOTNET_LAUNCH_BROWSER = "false" # Kein Aspire Dashboard im Produktionsbetrieb (Dashboard-Port auf 0 → kein Start) # Entfernen Sie die naechste Zeile, wenn Sie das Dashboard behalten moechten. $env:ASPIRE_ALLOW_UNSECURED_TRANSPORT = "true" # --- AppHost starten --- $appHostProject = Join-Path $projectRoot "GerbilManager.AppHost" Write-Host "Starte GerbilManager..." Write-Host " Projekt : $appHostProject" Write-Host " Umgebung: $($env:ASPNETCORE_ENVIRONMENT)" Write-Host " Fotos : $photosDir" Write-Host "" if ($Wait) { # Interaktiver Modus: blockiert bis Ctrl+C dotnet run --project $appHostProject --no-launch-profile } else { # Hintergrundmodus: startet minimiertes Fenster $pidFile = Join-Path $PSScriptRoot "..\gerbilmanager.pid" $proc = Start-Process "cmd.exe" ` -ArgumentList "/c", "dotnet run --project `"$appHostProject`" --no-launch-profile" ` -WorkingDirectory $projectRoot ` -WindowStyle Minimized ` -PassThru $proc.Id | Out-File -FilePath $pidFile -Encoding UTF8 -Force Write-Host "GerbilManager gestartet (PID $($proc.Id))." Write-Host "Frontend : http://localhost:5173" Write-Host "API : http://localhost:5179" Write-Host "PID-Datei: $pidFile" Write-Host "" Write-Host "Zum Beenden: deploy\scripts\Stop-GerbilManager.ps1" }