This commit is contained in:
master
2026-02-21 16:21:33 +02:00
parent 7e36c1f151
commit b911537870
116 changed files with 4365 additions and 5903 deletions

View File

@@ -141,22 +141,57 @@ function Test-Prerequisites {
}
}
# ─── 2. Check hosts file ───────────────────────────────────────────────────
# ─── 2. Check and install hosts file ─────────────────────────────────────
function Test-HostsFile {
Write-Step 'Checking hosts file for stella-ops.local entries'
$hostsPath = 'C:\Windows\System32\drivers\etc\hosts'
if (Test-Path $hostsPath) {
$content = Get-Content $hostsPath -Raw
if ($content -match 'stella-ops\.local') {
Write-Ok 'stella-ops.local entries found in hosts file'
$hostsSource = Join-Path $Root 'devops/compose/hosts.stellaops.local'
if (-not (Test-Path $hostsPath)) {
Write-Warn "Cannot read hosts file at $hostsPath"
return
}
$content = Get-Content $hostsPath -Raw
if ($content -match 'stella-ops\.local') {
Write-Ok 'stella-ops.local entries found in hosts file'
return
}
Write-Warn 'stella-ops.local entries NOT found in hosts file.'
if (-not (Test-Path $hostsSource)) {
Write-Warn "Hosts source file not found at $hostsSource"
Write-Host ' Add the hosts block from docs/dev/DEV_ENVIRONMENT_SETUP.md section 2' -ForegroundColor Yellow
return
}
# Check if running as Administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ($isAdmin) {
Write-Host ''
Write-Host ' Stella Ops needs ~50 hosts file entries for local development.' -ForegroundColor Yellow
Write-Host ' Source: devops/compose/hosts.stellaops.local' -ForegroundColor Yellow
Write-Host ''
$answer = Read-Host ' Add entries to hosts file now? (Y/n)'
if ($answer -eq '' -or $answer -match '^[Yy]') {
$hostsBlock = Get-Content $hostsSource -Raw
Add-Content -Path $hostsPath -Value "`n$hostsBlock"
Write-Ok 'Hosts entries added successfully'
} else {
Write-Warn 'stella-ops.local entries NOT found in hosts file.'
Write-Host ' Add the hosts block from docs/dev/DEV_ENVIRONMENT_SETUP.md section 2' -ForegroundColor Yellow
Write-Host ' to C:\Windows\System32\drivers\etc\hosts (run editor as Administrator)' -ForegroundColor Yellow
Write-Warn 'Skipped. Add them manually before accessing the platform.'
Write-Host " Copy from: $hostsSource" -ForegroundColor Yellow
}
} else {
Write-Warn "Cannot read hosts file at $hostsPath"
Write-Host ''
Write-Host ' Stella Ops needs ~50 hosts file entries for local development.' -ForegroundColor Yellow
Write-Host ' To install them, run this command in an elevated (Administrator) PowerShell:' -ForegroundColor Yellow
Write-Host ''
Write-Host " Get-Content '$hostsSource' | Add-Content '$hostsPath'" -ForegroundColor White
Write-Host ''
Write-Host ' Or re-run this script as Administrator to install them automatically.' -ForegroundColor Yellow
}
}
@@ -172,7 +207,7 @@ function Initialize-EnvFile {
} elseif (Test-Path $envExample) {
Copy-Item $envExample $envFile
Write-Ok "Copied $envExample -> $envFile"
Write-Warn 'Review .env and change POSTGRES_PASSWORD at minimum.'
Write-Warn 'For production, change POSTGRES_PASSWORD in .env.'
} else {
Write-Fail "Neither .env nor env/stellaops.env.example found in $ComposeDir"
exit 1
@@ -280,6 +315,8 @@ function Start-Platform {
function Test-Smoke {
Write-Step 'Running smoke tests'
# Infrastructure checks
$endpoints = @(
@{ Name = 'PostgreSQL'; Cmd = { docker exec stellaops-dev-postgres pg_isready -U stellaops 2>$null; $LASTEXITCODE -eq 0 } },
@{ Name = 'Valkey'; Cmd = { $r = docker exec stellaops-dev-valkey valkey-cli ping 2>$null; $r -eq 'PONG' } }
@@ -293,6 +330,59 @@ function Test-Smoke {
Write-Warn "$($ep.Name) check failed: $_"
}
}
# Platform container health summary
Write-Step 'Container health summary'
Push-Location $ComposeDir
try {
$composeFiles = @('docker-compose.dev.yml', 'docker-compose.stella-ops.yml')
$totalContainers = 0
$healthyContainers = 0
$unhealthyNames = @()
foreach ($cf in $composeFiles) {
if (-not (Test-Path $cf)) { continue }
$ps = docker compose -f $cf ps --format json 2>$null
if (-not $ps) { continue }
foreach ($line in $ps -split "`n") {
$line = $line.Trim()
if (-not $line) { continue }
try {
$svc = $line | ConvertFrom-Json
$totalContainers++
if (-not $svc.Health -or $svc.Health -eq 'healthy') {
$healthyContainers++
} else {
$unhealthyNames += $svc.Name
}
} catch {}
}
}
if ($totalContainers -gt 0) {
if ($healthyContainers -eq $totalContainers) {
Write-Ok "$healthyContainers/$totalContainers containers healthy"
} else {
Write-Warn "$healthyContainers/$totalContainers containers healthy"
foreach ($name in $unhealthyNames) {
Write-Warn " Unhealthy: $name"
}
}
}
# Platform endpoint check
try {
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect('stella-ops.local', 443)
$tcp.Close()
Write-Ok 'Platform accessible at https://stella-ops.local'
} catch {
Write-Warn 'Platform not yet accessible at https://stella-ops.local (may still be starting)'
}
}
finally {
Pop-Location
}
}
# ─── Main ───────────────────────────────────────────────────────────────────