#!/bin/bash # First run on the production node (run ON the node from ~/apps/company-atlas, ideally under nohup): # nohup bash deploy/first-run.sh > ~/company-atlas-data/logs/first-run.log 2>&1 & # 1. migrate + seed (idempotent) 2. mass onboarding (discovery → sensors) 3. first metrics/daily pass. # The PM2 scheduler (`catlas schedule`) keeps running in parallel: it also consumes the discovery queue and the due sensors, # so this script only accelerates the initial onboarding with a dedicated worker. set -euo pipefail cd "$(dirname "$0")/.." export PATH="$HOME/.local/bin:/opt/homebrew/opt/postgresql@17/bin:/opt/homebrew/bin:$PATH" export DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://companyatlas:companyatlas@127.0.0.1:5432/companyatlas} export CA_DATA_DIR=${CA_DATA_DIR:-$HOME/company-atlas-data} export CA_LOG_JSON=0 CATLAS=.venv/bin/catlas CONC=${CA_ONBOARDING_CONCURRENCY:-16} $CATLAS migrate | tail -1 $CATLAS seed | tail -2 echo "== onboarding (discovery + sensors) for every pending company, concurrency $CONC" $CATLAS onboard --concurrency "$CONC" || true echo "== first intelligence pass" $CATLAS process-changes --limit 5000 || true $CATLAS metrics --all || true $CATLAS daily --catch-up || true $CATLAS stats || true echo "== done $(date)"