-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-cli.sh
More file actions
executable file
·48 lines (40 loc) · 1.41 KB
/
Copy pathstart-cli.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.41 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# Open-Mem CLI instance — port 37889, data dir ~/.open-mem-cli/
# Used exclusively by Claude Code CLI (claude command) sessions.
# OpenClaw/TG uses the separate instance on port 37888.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG="/tmp/open-mem-cli.log"
HEALTH_URL="http://127.0.0.1:37889/health"
PIDFILE="/tmp/open-mem-cli.pid"
API_KEY="$(python3 -c "
import json
from pathlib import Path
cfg = json.load(open(Path.home() / '.openclaw' / 'openclaw.json'))
provider = cfg.get('models', {}).get('providers', {}).get('anthropic', {})
print(provider.get('authToken') or provider.get('apiKey') or '')
" 2>/dev/null || echo "")"
if [[ -z "$API_KEY" ]]; then
echo "[open-mem-cli] ERROR: Could not resolve Anthropic authToken/apiKey" >&2
exit 1
fi
pkill -f "open-mem-cli" 2>/dev/null || true
# Kill any bun server.ts on port 37889
lsof -ti:37889 | xargs kill -9 2>/dev/null || true
sleep 1
cd "$SCRIPT_DIR"
ANTHROPIC_API_KEY="$API_KEY" \
C_MEM_WORKER_PORT=37889 \
C_MEM_DATA_DIR="$HOME/.open-mem-cli" \
nohup bun run src/worker/server.ts >> "$LOG" 2>&1 &
echo $! > "$PIDFILE"
echo "[open-mem-cli] Started PID $! on port 37889 — logs at $LOG"
for i in $(seq 1 10); do
sleep 1
if curl -sf "$HEALTH_URL" > /dev/null 2>&1; then
echo "[open-mem-cli] Healthy ✅ (port 37889)"
exit 0
fi
done
echo "[open-mem-cli] WARNING: health check failed after 10s" >&2
exit 1