diff --git a/.claude/skills/xce-deploy-ha/SKILL.md b/.claude/skills/xce-deploy-ha/SKILL.md index 678758a..e2b056f 100644 --- a/.claude/skills/xce-deploy-ha/SKILL.md +++ b/.claude/skills/xce-deploy-ha/SKILL.md @@ -113,21 +113,36 @@ RAFT[p0] term=2 event=became_leader ## Clean restart -To wipe state and redeploy from scratch: +Stop all instances, clean up state, and restart without redeploying: ```bash +# 1. Stop running controllers kill -9 $(pgrep xce_controller) 2>/dev/null || true -for i in 1 2 3; do - rm -rf "$TOP/ctrl-$i/data/"* - rm -f "$TOP/logs/ctrl-$i.log" -done -# Then re-run steps 3–5 + +# 2. Run the generated cleanup script +# Keeps: ctrl-1/conf/* (primary config + current pointer), all certs +# Wipes: ctrl-{1..N}/data/*, ctrl-{2..N}/conf/*, logs/*.log +bash "$TOP/scripts/cleanup.sh" + +# 3. Restart all nodes +VERBOSE=-vvv "$TOP/scripts/start.sh" ctrl-1 & +sleep 0.5 +VERBOSE=-vvv "$TOP/scripts/start.sh" ctrl-2 & +sleep 0.5 +VERBOSE=-vvv "$TOP/scripts/start.sh" ctrl-3 & ``` -Or use the generated cleanup script (preserves primary config but wipes data/logs): -```bash -bash "$TOP/scripts/cleanup.sh" -``` +**What cleanup.sh preserves:** +- `ctrl-1/certs/` — TLS cert and key +- `ctrl-1/conf/cluster.bin.*` + `conf/current` — primary config (standbys re-receive via push) +- `ctrl-{2,3}/certs/` — TLS cert and key + +**What cleanup.sh removes:** +- All `data/` dirs (WAL, snapshots, `ha-term.bin`) — forces fresh election next start +- `ctrl-{2,3}/conf/` — standbys rebuild config from primary's `OPCode_replConfigPush` +- All `logs/*.log` — clean log slate + +If you need a full redeploy (different peers or new binary), run steps 3–5 instead. ## Troubleshooting diff --git a/src/controller/CLAUDE.md b/src/controller/CLAUDE.md index 32764c1..c5669be 100644 --- a/src/controller/CLAUDE.md +++ b/src/controller/CLAUDE.md @@ -97,11 +97,14 @@ grep -i "CTRL_PRIMARY\|Config committed" /tmp/xce-deploy/logs/ctrl-1.log | grep find /tmp/xce-deploy/ctrl-2/conf /tmp/xce-deploy/ctrl-3/conf -type f ``` -**Clean restart:** +**Clean restart** (keeps ctrl-1 config + all certs, wipes data/standby-conf/logs): ```bash kill -9 $(pgrep xce_controller) 2>/dev/null || true -for i in 1 2 3; do rm -rf /tmp/xce-deploy/ctrl-$i/data/* /tmp/xce-deploy/logs/ctrl-$i.log; done -# Then redeploy +bash /tmp/xce-deploy/scripts/cleanup.sh +# Then restart nodes (no redeploy needed) +VERBOSE=-vvv /tmp/xce-deploy/scripts/start.sh ctrl-1 & +sleep 0.5; VERBOSE=-vvv /tmp/xce-deploy/scripts/start.sh ctrl-2 & +sleep 0.5; VERBOSE=-vvv /tmp/xce-deploy/scripts/start.sh ctrl-3 & ``` See `.claude/skills/xce-deploy-ha/SKILL.md` for full troubleshooting reference.