SPB Git

spb/market-atlas

Public
3.7 KB

# Deploying Market Atlas on MacLustr

Production runs on M2U64 (Mac Studio M2 Ultra, 24 c / 64 GB) behind the MacLustr Tunnel (BHS64 Caddy → WireGuard wg1 10.67.0.12). Everything goes through the gateway M1M32 and mld (~/Desktop/cluster-skill/mld).

text
Internet → GoDaddy DNS (A www.market-atlas.co → 51.161.112.61)
        → BHS64 Caddy (TLS, WebSocket passthrough) → wg1 → M2U64:8380  market-atlas-core (Fastify edge: /v1 REST + WS + SSE, workers, connectors)
                                                                    └─ proxies every non-/v1 path → 127.0.0.1:8382  market-atlas-web (Next.js)
                                                                    └─ Postgres 17 Homebrew (db/role market_atlas) · ~/market-atlas-data (raw, archive, backups, logs)

Node prerequisites (present on M2U64 on 2026-09-12): node 25, pnpm 9, pm2, postgresql@17 (brew service), role/db market_atlas (password market_atlas, localhost only). Data dirs: ~/market-atlas-data/{raw,archive,backups,logs,cache}.

# Release procedure (from the laptop)

bash
cd ~/Desktop/Projets/apps-web/market-atlas
pnpm typecheck && pnpm test                                          # 1. types + 58+ unit/connector/consensus/calendar tests
deploy/render-manifest.sh --push                                     # 2. manifest with MA_ADMIN_TOKEN + HFMD_API_KEY → M1M32:~/dispatch/apps/market-atlas.json
~/Desktop/cluster-skill/mld stage ~/Desktop/Projets/apps-web/market-atlas market-atlas   # 3. laptop → gateway staging (sync_excludes)
~/Desktop/cluster-skill/mld deploy market-atlas --node M2U64        # 4. rsync → node, hooks (pnpm install, esbuild, migrate+seed, next build), PM2, health, tunnel route, registry
curl -s https://www.market-atlas.co/v1/health                        # 5. public check

The post_sync hooks build the API bundle (apps/api/dist), run migrations + seeds and build the web app. main.js also migrates and seeds at start (idempotent). mld heal (every 5 min on M1M32) restarts anything missing after a power cut and keeps the Caddy route pointing at the current node.

# Operations

bash
~/Desktop/cluster-skill/mld status | grep market-atlas
ssh M2U64 'pm2 logs market-atlas-core --lines 100 --nostream'
ssh M2U64 'cd ~/apps/market-atlas && export PATH=/opt/homebrew/opt/postgresql@17/bin:/opt/homebrew/bin:$PATH DATABASE_URL=postgres://market_atlas:market_atlas@127.0.0.1:5432/market_atlas MA_DATA_DIR=$HOME/market-atlas-data && node apps/api/dist/cli.js status'
ssh M2U64 '… node apps/api/dist/cli.js run cboe-delayed-quotes'      # one poll, printed
ssh M2U64 '… node apps/api/dist/cli.js replay 2026-09-12'            # re-normalize archived raw payloads offline
ssh M2U64 '… node apps/api/dist/cli.js backup'                       # pg_dump of metadata → ~/market-atlas-data/backups (also nightly ~04:00)
curl -s https://www.market-atlas.co/v1/stats | python3 -m json.tool  # live counters

Admin console: https://www.market-atlas.co/admin (token = deploy/.admin-token). Connector actions (pause/resume/restart/test), schema-change acknowledgements, storage/partitions, discovery form. Environment variables are listed in .env.example.

Retention: observations partitions older than MA_OBSERVATION_RETENTION_DAYS (45) are exported to ~/market-atlas-data/archive/<year>/…ndjson.gz then dropped (index in observation_archives). Bars, events, filings, quotes are permanent. Off-node copies of backups/ and archive/ should be scheduled to M1M32 (rsync -a M2U64:~/market-atlas-data/backups/ M1M32:~/backups/market-atlas/).

Apex domain: add A market-atlas.co → 51.161.112.61 at GoDaddy, then set "redirects": ["market-atlas.co"] in the manifest and redeploy.

Files · 194ce53c1aa3a7f9dd438c773dc8d99bee9c6246
Menu

Theme