Files
node/infra
2109d08e2c Fix/db startup resilience (#170)
* Keep node alive during database outages

* Fix startup-resilience gaps: reachable 503s, bounded retries, seamless handoff

- Route sqlx errors buried in anyhow chains back to AppError::Db and widen
  the unavailable class (Io/Tls/pool), so DB outages return 503 instead of
  500 — the previous 503 arm was unreachable dead code
- Bound each connect+migrate attempt (GITLAWB_DB_CONNECT_TIMEOUT_SECS) so a
  held migration advisory lock cannot wedge the startup retry loop forever
- Share one bound socket between the degraded and full servers and stop
  awaiting the degraded drain: no closed-port window during the handoff and
  no slow client can block the full server from starting
- Probe the database from /ready (2s bound) and gate Fly routing/deploys on
  it, so mid-life outages drain traffic and a bad DATABASE_URL fails the
  deploy visibly instead of going green; classify auth/catalog errors as
  likely-permanent (error-level log, straight to max backoff)
- Start the metrics listener before the DB connects so the degraded window
  is observable; degraded /health now returns 503 so peer pings and uptime
  monitors stop counting a DB-less node as alive
- Move the five GITLAWB_DB_* knobs onto clap Config (validated, in --help),
  drop the redundant outer connect timeout, default the pool to 20 conns,
  fix the backoff exponent cap that defeated GITLAWB_DB_RETRY_MAX_SECS, and
  strip at most one .git suffix in smart-HTTP repo names

* fix: apply CodeRabbit auto-fixes

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <[email protected]>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <[email protected]>
2026-07-10 09:44:02 +08:00
..
2026-07-10 09:44:02 +08:00
2026-06-05 22:38:53 +08:00

infra/

Deployment configuration, organized by target — one subdirectory per platform.

infra/
├── fly/
│   └── fly.toml    # Fly.io app config (gitlawb-node-test)
└── aws/            # Terraform: single EC2 + Docker (see aws/README.md)

Deploying to Fly.io

Run from the repo root so the Docker build context includes crates/, Cargo.toml, and bootstrap-peers.json:

fly deploy -c infra/fly/fly.toml

The dockerfile path inside fly.toml is resolved relative to the config file, so it points to ../../Dockerfile.

Deploying to AWS

See aws/README.md — Terraform for a single EC2 instance running the published ghcr.io/gitlawb/node image with Docker compose.

What intentionally stays at the repo root

  • Dockerfile / Dockerfile.bins — shared by the release CI workflow (.github/workflows/release.yml), scripts/build-bins.sh, and Fly builds.
  • docker-compose.yml — local dev stack; bundled into the macOS app by scripts/build-macos-app.sh and used for repo detection by the app.

Future targets should follow the same per-platform layout.