"feat: Added debug server and related components for improved development experience"
This commit is contained in:
137
start.ps1
Normal file
137
start.ps1
Normal file
@@ -0,0 +1,137 @@
|
||||
# Projektarbeit-MYP Startskript für Windows
|
||||
# Dieses Skript startet alle notwendigen Dienste für das MYP-Projekt
|
||||
|
||||
Write-Host "Starte MYP-Projekt..." -ForegroundColor Green
|
||||
|
||||
# SSH-Server (OpenSSH) prüfen und aktivieren
|
||||
Write-Host "Prüfe SSH-Server-Status..." -ForegroundColor Yellow
|
||||
|
||||
# Prüfen ob OpenSSH Server installiert ist
|
||||
$opensshService = Get-Service -Name 'sshd' -ErrorAction SilentlyContinue
|
||||
|
||||
if ($null -eq $opensshService) {
|
||||
Write-Host "OpenSSH Server ist nicht installiert. Versuche zu installieren..." -ForegroundColor Yellow
|
||||
|
||||
# Prüfen, ob Windows 10/11 mit der Option zum Installieren von Windows-Features
|
||||
if (Get-Command -Name "Add-WindowsCapability" -ErrorAction SilentlyContinue) {
|
||||
try {
|
||||
# OpenSSH Server installieren
|
||||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
||||
Write-Host "OpenSSH Server wurde installiert." -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Fehler bei der Installation des OpenSSH Servers. Bitte installieren Sie ihn manuell." -ForegroundColor Red
|
||||
Write-Host "Anleitung: https://docs.microsoft.com/de-de/windows-server/administration/openssh/openssh_install_firstuse" -ForegroundColor Cyan
|
||||
}
|
||||
} else {
|
||||
Write-Host "Windows-Feature zum Installieren von OpenSSH Server nicht verfügbar." -ForegroundColor Red
|
||||
Write-Host "Bitte installieren Sie OpenSSH Server manuell:" -ForegroundColor Red
|
||||
Write-Host "1. Öffnen Sie 'Einstellungen' > 'Apps' > 'Optionale Features'" -ForegroundColor Cyan
|
||||
Write-Host "2. Klicken Sie auf 'Feature hinzufügen' und wählen Sie 'OpenSSH Server'" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
# Erneut prüfen, ob der Dienst jetzt verfügbar ist
|
||||
$opensshService = Get-Service -Name 'sshd' -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
if ($null -ne $opensshService) {
|
||||
# OpenSSH Server beim Systemstart aktivieren
|
||||
Write-Host "Aktiviere OpenSSH Server beim Systemstart..." -ForegroundColor Yellow
|
||||
Set-Service -Name 'sshd' -StartupType Automatic
|
||||
|
||||
# OpenSSH Server starten, falls nicht bereits gestartet
|
||||
if ($opensshService.Status -ne 'Running') {
|
||||
Write-Host "Starte OpenSSH Server..." -ForegroundColor Yellow
|
||||
Start-Service -Name 'sshd'
|
||||
Write-Host "OpenSSH Server wurde gestartet." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "OpenSSH Server läuft bereits." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Firewall-Regel für SSH hinzufügen (Port 22)
|
||||
$firewallRule = Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue
|
||||
if ($null -eq $firewallRule) {
|
||||
Write-Host "Erstelle Firewall-Regel für OpenSSH Server..." -ForegroundColor Yellow
|
||||
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (TCP-In)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||
}
|
||||
} else {
|
||||
Write-Host "OpenSSH Server konnte nicht installiert werden. Bitte installieren Sie ihn manuell." -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Überprüfen, ob Docker Desktop läuft
|
||||
$dockerProcess = Get-Process "Docker Desktop" -ErrorAction SilentlyContinue
|
||||
if ($null -eq $dockerProcess) {
|
||||
Write-Host "Docker Desktop wird gestartet..." -ForegroundColor Yellow
|
||||
Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe"
|
||||
|
||||
# Warten, bis Docker Desktop vollständig geladen ist
|
||||
Write-Host "Warte, bis Docker Desktop bereit ist..." -ForegroundColor Yellow
|
||||
$retryCount = 0
|
||||
$maxRetries = 30
|
||||
|
||||
do {
|
||||
Start-Sleep -Seconds 5
|
||||
$retryCount++
|
||||
$dockerRunning = docker info 2>$null
|
||||
|
||||
if ($retryCount -gt $maxRetries) {
|
||||
Write-Host "Docker Desktop konnte nicht gestartet werden. Bitte starten Sie Docker Desktop manuell und führen Sie dieses Skript erneut aus." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
} while ($null -eq $dockerRunning)
|
||||
|
||||
Write-Host "Docker Desktop ist bereit." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Überprüfen, ob die Container bereits laufen
|
||||
$runningContainers = docker ps --format "{{.Names}}" | Select-String -Pattern "myp-backend|myp-rp|myp-caddy"
|
||||
|
||||
if ($runningContainers.Count -eq 3) {
|
||||
Write-Host "Alle MYP-Container laufen bereits." -ForegroundColor Green
|
||||
} else {
|
||||
# Container starten
|
||||
Write-Host "Starte MYP-Container..." -ForegroundColor Yellow
|
||||
|
||||
# Ins Projektverzeichnis wechseln
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Set-Location -Path $scriptPath
|
||||
|
||||
# Docker-Compose ausführen
|
||||
docker-compose up -d
|
||||
|
||||
# Warten, bis alle Container laufen
|
||||
Write-Host "Warte, bis alle Container bereit sind..." -ForegroundColor Yellow
|
||||
$allRunning = $false
|
||||
$retryCount = 0
|
||||
$maxRetries = 30
|
||||
|
||||
do {
|
||||
Start-Sleep -Seconds 5
|
||||
$retryCount++
|
||||
|
||||
$backendHealth = docker inspect --format='{{.State.Health.Status}}' myp-backend 2>$null
|
||||
$frontendHealth = docker inspect --format='{{.State.Health.Status}}' myp-rp 2>$null
|
||||
|
||||
if ($backendHealth -eq "healthy" -and $frontendHealth -eq "healthy") {
|
||||
$allRunning = $true
|
||||
}
|
||||
|
||||
if ($retryCount -gt $maxRetries) {
|
||||
Write-Host "Zeitüberschreitung beim Warten auf Container. Bitte überprüfen Sie den Status mit 'docker ps'." -ForegroundColor Yellow
|
||||
break
|
||||
}
|
||||
} while (-not $allRunning)
|
||||
|
||||
if ($allRunning) {
|
||||
Write-Host "Alle MYP-Container sind bereit und laufen." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
# Informationen zur Anwendung anzeigen
|
||||
Write-Host "`nMYP-Anwendung ist jetzt verfügbar unter:" -ForegroundColor Cyan
|
||||
Write-Host " * http://localhost" -ForegroundColor White
|
||||
Write-Host " * http://192.168.0.5:5000 (Backend API direkt)" -ForegroundColor White
|
||||
Write-Host "`nDas Backend ist unter der festen IP 192.168.0.5 erreichbar." -ForegroundColor Cyan
|
||||
Write-Host "Die API kann über http://localhost/api/ angesprochen werden." -ForegroundColor Cyan
|
||||
Write-Host "`nOpenSSH Server ist aktiviert und wird beim Systemstart automatisch gestartet." -ForegroundColor Cyan
|
||||
|
||||
Write-Host "`nZum Beenden der Anwendung verwenden Sie: docker-compose down" -ForegroundColor Yellow
|
||||
Reference in New Issue
Block a user