-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathstart_canopy_testnet.sh
More file actions
62 lines (54 loc) · 2.24 KB
/
start_canopy_testnet.sh
File metadata and controls
62 lines (54 loc) · 2.24 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
# start_canopy_testnet.sh — Launch a clean, isolated Canopy testnet instance
#
# Runs on port 7780 (web) with its own fresh database and NO P2P mesh.
# CANOPY_DISABLE_MESH=true means it never auto-joins the main instance or
# any other peer on the LAN. Agents connect via HTTP API keys only.
#
# This does NOT touch or interfere with the main instance (7770).
#
# Usage:
# ./start_canopy_testnet.sh # start testnet (preserves existing DB)
# ./start_canopy_testnet.sh --reset # wipe DB and start completely fresh
# ---------------------------------------------------------------------------
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
TESTNET_DIR="$SCRIPT_DIR/data/testnet"
TESTNET_DB="$TESTNET_DIR/canopy.db"
TESTNET_PORT=7780
# Stable secret key — sessions survive restarts during a test session.
# Generate a persistent key the first time and reuse it across restarts.
TESTNET_KEY_FILE="$TESTNET_DIR/.testnet_secret_key"
mkdir -p "$TESTNET_DIR"
if [[ ! -f "$TESTNET_KEY_FILE" ]]; then
(umask 077; python3 -c "import secrets; print(secrets.token_hex(32))" > "$TESTNET_KEY_FILE")
fi
IFS= read -r TESTNET_SECRET_KEY < "$TESTNET_KEY_FILE"
# --reset flag: wipe the testnet database and start fresh
if [[ "${1:-}" == "--reset" ]]; then
echo "⚠️ Resetting testnet — wiping database..."
rm -f "$TESTNET_DB"
echo " Cleared: $TESTNET_DB"
fi
mkdir -p "$TESTNET_DIR"
echo ""
echo "🌿 Canopy TESTNET (standalone, mesh-off)"
echo " Web UI : http://localhost:$TESTNET_PORT"
echo " P2P mesh: DISABLED (will not join main instance or LAN peers)"
echo " Database: $TESTNET_DB"
echo ""
if [[ ! -f "$TESTNET_DB" ]]; then
echo " ➜ First run! Open http://localhost:$TESTNET_PORT and register"
echo " the admin account, then set up channels + agent API keys."
fi
echo " Press Ctrl+C to stop."
echo ""
# CANOPY_DISABLE_MESH prevents auto-joining the main mesh on the same machine
export CANOPY_DISABLE_MESH=true
export CANOPY_PORT="$TESTNET_PORT"
export CANOPY_DATA_DIR="$TESTNET_DIR"
export CANOPY_DATABASE_PATH="$TESTNET_DB"
export CANOPY_SECRET_KEY="$TESTNET_SECRET_KEY"
python3 run.py