-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathmnemo-cc-sync-loop.sh
More file actions
executable file
·25 lines (22 loc) · 995 Bytes
/
Copy pathmnemo-cc-sync-loop.sh
File metadata and controls
executable file
·25 lines (22 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# mnemo-cc-sync-loop — periodic Claude Code → Mnemo Cortex sync.
#
# Calls mnemo-cc-sync.py every ${INTERVAL} seconds. Designed to run
# under systemd with Restart=on-failure so it self-heals from transient errors.
#
# Configuration (env vars, all optional — see mnemo-cc-sync.py):
# MNEMO_URL Mnemo Cortex base URL (default: http://localhost:50001)
# MNEMO_AGENT_ID Agent ID (default: cc)
# MNEMO_CC_SESSIONS_DIR Where Claude Code stores .jsonl files
# MNEMO_CC_OFFSET_FILE Sync offset state file
# MNEMO_CC_SYNC_INTERVAL Seconds between syncs (default: 60)
#
# SIGTERM force-flushes pending messages before exit so nothing is stranded.
INTERVAL=${MNEMO_CC_SYNC_INTERVAL:-60}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SYNC="$SCRIPT_DIR/mnemo-cc-sync.py"
trap 'python3 "$SYNC" --force; exit 0' TERM INT
while true; do
python3 "$SYNC" || echo "[cc-sync-loop] sync failed (will retry)"
sleep "$INTERVAL"
done