"Update backend installation scripts for consistency"

This commit is contained in:
2025-05-23 09:54:17 +02:00
parent 72230c342d
commit ffc32959e0
3 changed files with 120 additions and 46 deletions

View File

@@ -36,6 +36,58 @@ function Write-Error {
Write-Log "FEHLER: $Message" -Color $Red
}
# Verbesserte Funktion zum Parsen der Umgebungsvariablen
function Set-EnvironmentFromFile {
param([string]$FilePath)
if (-not (Test-Path $FilePath)) {
Write-Warning "$FilePath nicht gefunden"
return
}
Write-Log "⚙️ Lade Umgebungsvariablen aus $FilePath..." -Color $Blue
try {
$EnvContent = Get-Content $FilePath -Raw
$Lines = $EnvContent -split "`r?`n"
foreach ($Line in $Lines) {
# Überspringe leere Zeilen und Kommentare
if ([string]::IsNullOrWhiteSpace($Line) -or $Line.TrimStart().StartsWith('#')) {
continue
}
# Finde den ersten = Zeichen
$EqualIndex = $Line.IndexOf('=')
if ($EqualIndex -le 0) {
continue
}
# Extrahiere Key und Value
$Key = $Line.Substring(0, $EqualIndex).Trim()
$Value = $Line.Substring($EqualIndex + 1).Trim()
# Entferne umgebende Anführungszeichen, falls vorhanden
if (($Value.StartsWith('"') -and $Value.EndsWith('"')) -or
($Value.StartsWith("'") -and $Value.EndsWith("'"))) {
$Value = $Value.Substring(1, $Value.Length - 2)
}
# Setze Umgebungsvariable
if (-not [string]::IsNullOrWhiteSpace($Key)) {
[Environment]::SetEnvironmentVariable($Key, $Value, "Process")
Write-Log "Geladen: $Key" -Color $Blue
}
}
Write-Success "Umgebungsvariablen erfolgreich geladen"
} catch {
Write-Error "Fehler beim Laden der Umgebungsvariablen: $_"
Write-Warning "Verwende Standard-Umgebungsvariablen"
}
}
# Banner
Write-Host "========================================" -ForegroundColor $Blue
Write-Host "🏭 MYP Backend - Windows Installation" -ForegroundColor $Blue
@@ -158,23 +210,8 @@ if (Test-Path "requirements.txt") {
# Umgebungskonfiguration
Write-Log "⚙️ Konfiguriere Umgebung..." -Color $Blue
if (Test-Path "env.backend") {
Write-Log "Umgebungskonfiguration gefunden: env.backend"
# Lade Umgebungsvariablen für Tests
$EnvContent = Get-Content "env.backend"
foreach ($Line in $EnvContent) {
if ($Line -match "^([^#][^=]+)=(.*)$") {
$Key = $Matches[1].Trim()
$Value = $Matches[2].Trim()
[Environment]::SetEnvironmentVariable($Key, $Value, "Process")
}
}
Write-Success "Umgebungsvariablen geladen"
} else {
Write-Warning "env.backend nicht gefunden"
}
# Lade Umgebungsvariablen für Tests
Set-EnvironmentFromFile "env.backend"
# Datenbank initialisieren
Write-Log "🗄️ Initialisiere Datenbank..." -Color $Blue
@@ -226,7 +263,7 @@ Write-Host ""
Write-Host "📋 Nächste Schritte:" -ForegroundColor $Blue
Write-Host "1. Backend starten:" -ForegroundColor $White
Write-Host " .\start-backend-server.ps1" -ForegroundColor $Yellow
Write-Host " .\start-backend-server.ps1 -Development" -ForegroundColor $Yellow
Write-Host ""
Write-Host "2. Health-Check testen:" -ForegroundColor $White
Write-Host " curl http://localhost:5000/monitoring/health/simple" -ForegroundColor $Yellow