<# .SYNOPSIS Start the Elysium stack safely. .PARAMETER LogLevel error, warn, log (default), debug, verbose .PARAMETER Build Rebuild images .PARAMETER Nuke Full reset: remove containers, volumes, wipe DBs, rebuild no-cache #>
param( [ValidateSet("error","warn","log","debug","verbose")] [string]$LogLevel = "log",
[switch]$Build,
[switch]$Nuke
)
$ErrorActionPreference = "Stop"
function Wait-For-Container { param($ContainerName)
Write-Host " Waiting for $ContainerName to be healthy..."
do {
Start-Sleep -Seconds 3
$status = docker inspect --format='{{.State.Health.Status}}' $ContainerName 2>$null
} until ($status -eq "healthy")
Write-Host " $ContainerName is healthy."
}
Write-Host "==> Starting Elysium stack..."
-------------------------------------------------
NUKE MODE
-------------------------------------------------
if ($Nuke) {
Write-Host "==> [NUKE] Removing containers + volumes..."
docker compose down -v --remove-orphans | Out-Null
if (Test-Path "data") {
Write-Host "==> [NUKE] Removing data folder..."
Remove-Item -Recurse -Force "data"
}
Write-Host "==> [NUKE] Rebuilding images (no cache)..."
docker compose build --no-cache
# ---- Neo4j ----
Write-Host "==> [NUKE] Starting neo4j..."
docker compose up -d neo4j
Wait-For-Container "elysium-neo4j"
Write-Host " Wiping neo4j database..."
docker compose exec neo4j cypher-shell \`
-u neo4j -p elysium\_secret \`
"MATCH (n) DETACH DELETE n" | Out-Null
# ---- Postgres ----
Write-Host "==> [NUKE] Starting postgres..."
docker compose up -d postgres
Wait-For-Container "elysium-postgres"
Write-Host " Truncating postgres tables..."
$sql = @"
DO \$\$ DECLARE r RECORD; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename <> 'prompts' LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE'; END LOOP; END \$\$; "@
$sql | docker compose exec -T postgres psql -U elysium -d elysium | Out-Null
Write-Host "==> [NUKE] Database reset complete."
}
-------------------------------------------------
BUILD ONLY
-------------------------------------------------
elseif ($Build) { Write-Host "==> Building images..." docker compose build }
-------------------------------------------------
START ALL SERVICES
-------------------------------------------------
Write-Host "==> Starting all services..." docker compose up --force-recreate
Comments
No comments yet
Please complete the captcha