Files
forge/scripts/stop_dharma.sh
T
Will Anderson cbeb9c02eb build DHARMA network: 19 soul Engram instances with full peer wiring
- Add scripts/: install_soul.py, install_all.py, launch_dharma.sh, stop_dharma.sh, wire_peers.py
- Move all seeds into seeds/ directory (consolidated from root-level scattered files)
- Update registry.json with engram_root_id, engram_api_key, engram_url for all 19 installed souls
- Add src/soul.el, src/research.el; remove src/daemon.el
- .gitignore: exclude imprints/, log/, sandboxes/ (runtime data)
- Remove superseded scripts: deploy.py, install_imprints.py, reinstall_imprints.py, fix_collision.py
- Remove old root-level seed files and shell scripts superseded by scripts/ versions

Key: native engram binary uses _auth body field, per-soul keys ntn-<slug>-2026,
DharmaPeer graph edges for peer wiring, sanitize_content() for JSON safety.
190/190 peer pairs wired successfully.
2026-05-03 03:09:27 -05:00

67 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# DHARMA network — stop all running soul Engrams.
#
# Primary: reads PIDs from forge/imprints/<slug>/engram.pid
# Fallback: port scan kill (ports 8801-8819)
#
# Usage:
# ./stop_dharma.sh stop all soul Engrams
# ./stop_dharma.sh <slug> stop one soul by slug
set -euo pipefail
FORGE=/Users/will/Development/neuron-technologies/forge
REGISTRY="$FORGE/registry.json"
FILTER="${1:-}"
stopped=0
missed=0
if [ ! -f "$REGISTRY" ]; then
echo "[dharma] ERROR: registry.json not found at $REGISTRY"
exit 1
fi
while IFS='|' read -r slug port db_path; do
[ -z "$slug" ] && continue
if [ -n "$FILTER" ] && [ "$slug" != "$FILTER" ]; then
continue
fi
full_db_path="$FORGE/$db_path"
pid_file="$full_db_path/engram.pid"
if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
if kill -0 "$pid" 2>/dev/null; then
kill "$pid"
echo "[dharma] stopped $slug (pid=$pid port=$port)"
stopped=$((stopped + 1))
else
echo "[dharma] $slug (pid=$pid) already gone"
fi
rm -f "$pid_file"
else
# Fallback: kill by port
pids=$(lsof -ti tcp:"$port" 2>/dev/null || true)
if [ -n "$pids" ]; then
echo "$pids" | xargs kill 2>/dev/null || true
echo "[dharma] stopped $slug by port kill (port=$port)"
stopped=$((stopped + 1))
else
missed=$((missed + 1))
fi
fi
done < <(python3 - "$REGISTRY" <<'PYEOF'
import json, sys
reg = json.load(open(sys.argv[1]))
for imp in reg["imprints"]:
print(f"{imp['slug']}|{imp['engram_port']}|{imp.get('engram_db_path', 'imprints/' + imp['slug'])}")
PYEOF
)
echo ""
echo "[dharma] stopped=$stopped not_running=$missed"