ui fixes
This commit is contained in:
@@ -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 ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -123,16 +123,51 @@ check_prerequisites() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ─── 2. Check hosts file ───────────────────────────────────────────────────
|
||||
# ─── 2. Check and install hosts file ─────────────────────────────────────
|
||||
|
||||
check_hosts() {
|
||||
step 'Checking hosts file for stella-ops.local entries'
|
||||
local hosts_source="${ROOT}/devops/compose/hosts.stellaops.local"
|
||||
|
||||
if grep -q 'stella-ops\.local' /etc/hosts 2>/dev/null; then
|
||||
ok 'stella-ops.local entries found in /etc/hosts'
|
||||
else
|
||||
warn 'stella-ops.local entries NOT found in /etc/hosts.'
|
||||
return
|
||||
fi
|
||||
|
||||
warn 'stella-ops.local entries NOT found in /etc/hosts.'
|
||||
|
||||
if [[ ! -f "$hosts_source" ]]; then
|
||||
warn "Hosts source file not found at $hosts_source"
|
||||
echo ' Add the hosts block from docs/dev/DEV_ENVIRONMENT_SETUP.md section 2'
|
||||
echo ' to /etc/hosts (use sudo).'
|
||||
return
|
||||
fi
|
||||
|
||||
echo ''
|
||||
echo ' Stella Ops needs ~50 hosts file entries for local development.'
|
||||
echo " Source: devops/compose/hosts.stellaops.local"
|
||||
echo ''
|
||||
printf ' Add entries to /etc/hosts now? (Y/n) '
|
||||
read -r answer
|
||||
|
||||
if [[ -z "$answer" || "$answer" =~ ^[Yy] ]]; then
|
||||
if [[ "$(id -u)" -eq 0 ]]; then
|
||||
printf '\n' >> /etc/hosts
|
||||
cat "$hosts_source" >> /etc/hosts
|
||||
ok 'Hosts entries added successfully'
|
||||
else
|
||||
echo ''
|
||||
echo ' Adding hosts entries requires sudo...'
|
||||
if sudo sh -c "printf '\n' >> /etc/hosts && cat '$hosts_source' >> /etc/hosts"; then
|
||||
ok 'Hosts entries added successfully'
|
||||
else
|
||||
warn 'Failed to add hosts entries. Add them manually:'
|
||||
echo " sudo sh -c 'cat $hosts_source >> /etc/hosts'"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
warn 'Skipped. Add them manually before accessing the platform:'
|
||||
echo " sudo sh -c 'cat $hosts_source >> /etc/hosts'"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -148,7 +183,7 @@ ensure_env() {
|
||||
elif [[ -f "$env_example" ]]; then
|
||||
cp "$env_example" "$env_file"
|
||||
ok "Copied $env_example -> $env_file"
|
||||
warn 'Review .env and change POSTGRES_PASSWORD at minimum.'
|
||||
warn 'For production, change POSTGRES_PASSWORD in .env.'
|
||||
else
|
||||
fail "Neither .env nor env/stellaops.env.example found in $COMPOSE_DIR"
|
||||
exit 1
|
||||
@@ -235,6 +270,7 @@ start_platform() {
|
||||
smoke_test() {
|
||||
step 'Running smoke tests'
|
||||
|
||||
# Infrastructure checks
|
||||
if docker exec stellaops-dev-postgres pg_isready -U stellaops &>/dev/null; then
|
||||
ok 'PostgreSQL'
|
||||
else
|
||||
@@ -247,6 +283,49 @@ smoke_test() {
|
||||
else
|
||||
warn 'Valkey not responding'
|
||||
fi
|
||||
|
||||
# Platform container health summary
|
||||
step 'Container health summary'
|
||||
cd "$COMPOSE_DIR"
|
||||
|
||||
local total=0
|
||||
local healthy=0
|
||||
local unhealthy_names=""
|
||||
|
||||
for cf in docker-compose.dev.yml docker-compose.stella-ops.yml; do
|
||||
[[ ! -f "$cf" ]] && continue
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
local name; name=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin).get('Name',''))" 2>/dev/null || true)
|
||||
local h; h=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin).get('Health',''))" 2>/dev/null || true)
|
||||
total=$((total + 1))
|
||||
if [[ -z "$h" || "$h" == "healthy" ]]; then
|
||||
healthy=$((healthy + 1))
|
||||
else
|
||||
unhealthy_names="${unhealthy_names} Unhealthy: ${name}\n"
|
||||
fi
|
||||
done < <(docker compose -f "$cf" ps --format json 2>/dev/null)
|
||||
done
|
||||
|
||||
if (( total > 0 )); then
|
||||
if (( healthy == total )); then
|
||||
ok "$healthy/$total containers healthy"
|
||||
else
|
||||
warn "$healthy/$total containers healthy"
|
||||
[[ -n "$unhealthy_names" ]] && printf " \033[0;33m%b\033[0m" "$unhealthy_names"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Platform endpoint check
|
||||
if curl -sk --connect-timeout 5 -o /dev/null -w '' https://stella-ops.local 2>/dev/null; then
|
||||
ok 'Platform accessible at https://stella-ops.local'
|
||||
elif bash -c "echo >/dev/tcp/stella-ops.local/443" 2>/dev/null; then
|
||||
ok 'Platform listening on https://stella-ops.local (TLS handshake pending)'
|
||||
else
|
||||
warn 'Platform not yet accessible at https://stella-ops.local (may still be starting)'
|
||||
fi
|
||||
|
||||
cd "$ROOT"
|
||||
}
|
||||
|
||||
# ─── Main ───────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user