-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-local.sh
More file actions
executable file
·184 lines (167 loc) · 4.53 KB
/
run-local.sh
File metadata and controls
executable file
·184 lines (167 loc) · 4.53 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
# SQLite Zone Demo
# Runs sequencer and/or indexer without Docker (works on ARM Mac)
#
# Usage:
# ./run-local.sh <service> [--env-file /path/to/.env-local] [--clean]
#
# Services:
# sequencer - Run only the sequencer
# indexer - Run only the indexer
#
# Examples:
# ./run-local.sh sequencer --env-file ~/Eng/offsite-sequencer-env/.env-local
# ./run-local.sh indexer --env-file ~/Eng/offsite-sequencer-env/.env-local
#
# Required env vars:
# SEQUENCER_NODE_ENDPOINT - LB node HTTP endpoint for sequencer
# INDEXER_NODE_ENDPOINT - LB node HTTP endpoint for indexer
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/logos-blockchain" && pwd)"
DATA_DIR="$SCRIPT_DIR/data"
# Will be overwritten by env file if set there
BUILD_DIR="$SCRIPT_DIR"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Parse service argument (first positional arg)
SERVICE="sequencer"
if [[ $# -gt 0 && ! "$1" =~ ^-- ]]; then
SERVICE="$1"
shift
fi
# Validate service
case $SERVICE in
sequencer|indexer)
;;
*)
echo -e "${RED}Unknown service: $SERVICE${NC}"
echo "Valid services: sequencer, indexer"
exit 1
;;
esac
# Parse remaining arguments
ENV_FILE=""
CLEAN_START=false
while [[ $# -gt 0 ]]; do
case $1 in
--env-file)
ENV_FILE="$2"
shift 2
;;
--clean)
CLEAN_START=true
shift
;;
--sequencer-node-endpoint)
SEQUENCER_NODE_ENDPOINT="$2"
shift 2
;;
--sequencer-node-auth-username)
SEQUENCER_NODE_AUTH_USERNAME="$2"
shift 2
;;
--sequencer-node-auth-password)
SEQUENCER_NODE_AUTH_PASSWORD="$2"
shift 2
;;
--sequencer-db-path)
SEQUENCER_DB_PATH="$2"
shift 2
;;
--sequencer-signing-key-path)
SEQUENCER_SIGNING_KEY_PATH="$2"
shift 2
;;
--queue-file)
QUEUE_FILE="$2"
shift 2
;;
--checkpoint-path)
CHECKPOINT_PATH="$2"
shift 2
;;
--indexer-node-endpoint)
INDEXER_NODE_ENDPOINT="$2"
shift 2
;;
--indexer-node-auth-username)
INDEXER_NODE_AUTH_USERNAME="$2"
shift 2
;;
--indexer-node-auth-password)
INDEXER_NODE_AUTH_PASSWORD="$2"
shift 2
;;
--channel-path)
export CHANNEL_PATH="$2"
echo "hi"
shift 2
;;
--indexer-db-path)
INDEXER_DB_PATH=="$2"
shift 2
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
exit 1
;;
esac
done
# Load env file if provided
if [ -n "$ENV_FILE" ]; then
if [ -f "$ENV_FILE" ]; then
echo -e "${BLUE}Loading environment from: $ENV_FILE${NC}"
set -a
source "$ENV_FILE"
set +a
fi
fi
if [ ${#missing_vars[@]} -ne 0 ]; then
echo -e "${RED}Error: Missing required environment variables:${NC}"
for var in "${missing_vars[@]}"; do
echo " - $var"
done
echo ""
echo "See .env-local.example for the required format."
exit 1
fi
# Clean data directory if requested
if [ "$CLEAN_START" = true ]; then
echo -e "${YELLOW}Cleaning data directory...${NC}"
rm -rf "$DATA_DIR"
fi
# Create data directory (needed for channel ID file)
mkdir -p "$DATA_DIR"
# Get local IP for sharing
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || hostname -I 2>/dev/null | awk '{print $1}' || echo "localhost")
# Check if binaries exist, if not build them
SEQUENCER_BIN="$BUILD_DIR/target/release/demo-sqlite-sequencer"
INDEXER_BIN="$BUILD_DIR/target/release/demo-sqlite-indexer"
if [[ "$SERVICE" == "sequencer" ]]; then
echo -e "${YELLOW}Building sequencer...${NC}"
cd "$SCRIPT_DIR"
cargo build --release -p demo-sqlite-sequencer
fi
if [[ "$SERVICE" == "indexer" ]]; then
echo -e "${YELLOW}Building indexer...${NC}"
cd "$SCRIPT_DIR"
cargo build --release -p demo-sqlite-indexer
fi
# Run the selected service(s)
case $SERVICE in
sequencer)
echo -e "${GREEN}Starting sequencer...${NC}"
cd "$SCRIPT_DIR"
exec "$SEQUENCER_BIN"
;;
indexer)
echo -e "${GREEN}Starting indexer...${NC}"
cd "$SCRIPT_DIR"
exec "$INDEXER_BIN"
;;
esac