#!/usr/bin/env bash # DHARMA network — start all 19 soul Engrams in background. # Each soul gets their own Engram instance, data directory, and port. # Neuron's Engram stays untouched at localhost:8742. # # Usage: # ./launch_dharma.sh start all soul Engrams # ./launch_dharma.sh start a single soul by slug # # PIDs are written to /tmp/dharma-pids for stop_dharma.sh set -euo pipefail FORGE=/Users/will/Development/neuron-technologies/forge ENGRAM_BIN=/Users/will/Development/neuron-technologies/foundation/engram/dist/engram PID_FILE=/tmp/dharma-pids if [ ! -x "$ENGRAM_BIN" ]; then echo "[dharma] ERROR: engram binary not found at $ENGRAM_BIN" echo "[dharma] Build it with: cd /Users/will/Development/neuron-technologies/foundation/engram && cargo build --release" exit 1 fi # Soul definitions: slug|port SOULS=( "bobby-anderson|8801" "alan-turing|8802" "albert-einstein|8803" "nikola-tesla|8804" "leonardo-da-vinci|8805" "richard-feynman|8806" "carl-sagan|8807" "rene-descartes|8808" "robin-williams|8809" "frederick-douglass|8810" "marcus-aurelius|8811" "friedrich-nietzsche|8812" "james-baldwin|8813" "ada-lovelace|8814" "harriet-tubman|8815" "virginia-woolf|8816" "hedy-lamarr|8817" "marie-curie|8818" "helen-keller|8819" ) # Optional single-soul filter FILTER="${1:-}" # Ensure PID file is clean on fresh launch (without filter) if [ -z "$FILTER" ]; then > "$PID_FILE" fi started=0 skipped=0 for entry in "${SOULS[@]}"; do slug="${entry%|*}" port="${entry#*|}" # If a filter is specified, only start matching soul if [ -n "$FILTER" ] && [ "$slug" != "$FILTER" ]; then continue fi # Skip if already listening on that port if lsof -ti tcp:"$port" >/dev/null 2>&1; then echo "[dharma] $slug already running on port $port — skipping" skipped=$((skipped + 1)) continue fi db_path="$FORGE/imprints/$slug" mkdir -p "$db_path" api_key="ntn-${slug}-2026" log_file="$FORGE/log/dharma-${slug}.log" mkdir -p "$FORGE/log" echo "[dharma] starting $slug on :$port (db: imprints/$slug)" ENGRAM_DB_PATH="$db_path" \ ENGRAM_BIND="0.0.0.0:$port" \ ENGRAM_API_KEY="$api_key" \ ENGRAM_PEER_NAME="dharma-$slug" \ "$ENGRAM_BIN" >> "$log_file" 2>&1 & pid=$! echo "$pid $slug $port" >> "$PID_FILE" started=$((started + 1)) done echo "" echo "[dharma] started=$started skipped=$skipped" echo "[dharma] pids recorded in $PID_FILE" echo "[dharma] logs in $FORGE/log/dharma-.log" echo "" echo "[dharma] verify with:" echo " curl -s http://localhost:8801/stats # bobby-anderson" echo " curl -s http://localhost:8819/stats # helen-keller"