From 85343ab481ac19612406443d78dd42c130967441 Mon Sep 17 00:00:00 2001 From: Dorian Date: Sat, 14 Mar 2026 03:06:20 +0000 Subject: [PATCH] feat: add tiered startup ordering to first-boot containers - Tier 1: Databases & Core Infrastructure (Bitcoin, MariaDB, Postgres) - Tier 2: Core Services (LND, Fedimint) with 5s stabilization delay - Tier 3: Applications (Home Assistant, Grafana, etc.) with 5s delay - Matches health_monitor.rs StartupTier approach Co-Authored-By: Claude Opus 4.6 (1M context) --- loop/plan.md | 2 +- scripts/first-boot-containers.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/loop/plan.md b/loop/plan.md index aab63924..bf30824a 100644 --- a/loop/plan.md +++ b/loop/plan.md @@ -305,7 +305,7 @@ Every test must pass **10 consecutive times** from BOTH .228→.198 AND .198→. - [x] **ISO-02** — Added swap creation to first-boot-containers.sh. Calculates 50% of RAM (min 2GB, max 8GB), creates /swapfile, sets permissions 600, mkswap + swapon, adds to /etc/fstab. Skips if swap already exists. Runs before container creation so apps have swap available. -- [ ] **ISO-03** — Add container dependency ordering to first-boot. Same startup ordering as CONT-02 but for the first-boot-containers.sh script. **Acceptance**: Fresh install starts containers in dependency order with zero crash loops. +- [x] **ISO-03** — Added tiered startup ordering to first-boot-containers.sh. Tier 1: Databases & Core Infrastructure (Bitcoin, MariaDB, Postgres, Electrs). Tier 2: Core Services (LND, Fedimint) with 5s stabilization delay. Tier 3: Applications (Home Assistant, Grafana, etc.) with 5s delay. Matches CONT-02's StartupTier approach. --- diff --git a/scripts/first-boot-containers.sh b/scripts/first-boot-containers.sh index 3632887f..6926fb12 100644 --- a/scripts/first-boot-containers.sh +++ b/scripts/first-boot-containers.sh @@ -62,6 +62,9 @@ fi # Ensure network exists (matches deploy) $DOCKER network create archy-net 2>/dev/null || true +# ── Tier 1: Databases & Core Infrastructure ────────────────────────────── +log "=== Tier 1: Databases & Core Infrastructure ===" + # 1. Bitcoin Knots (matches deploy exactly) if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -qE 'bitcoin-knots|archy-bitcoin-knots'; then log "Creating Bitcoin Knots..." @@ -202,6 +205,10 @@ if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -q btcpay-server; then docker.io/btcpayserver/btcpayserver:1.13.5 2>>"$LOG" || true fi +# ── Tier 2: Core Services ───────────────────────────────────────────────── +log "=== Tier 2: Core Services ===" +sleep 5 # Let databases stabilize + # 4. LND if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -qE '^lnd$'; then log "Creating LND..." @@ -296,6 +303,10 @@ if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -q fedimint-gateway; th fi fi +# ── Tier 3: Applications ────────────────────────────────────────────────── +log "=== Tier 3: Applications ===" +sleep 5 # Let core services stabilize + # 6. Home Assistant if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -qE 'homeassistant|home-assistant'; then log "Creating Home Assistant..."