v0.3.5 - nip42 implemented
This commit is contained in:
@@ -8,6 +8,7 @@ echo "=== C Nostr Relay Build and Restart Script ==="
|
||||
# Parse command line arguments
|
||||
PRESERVE_DATABASE=false
|
||||
HELP=false
|
||||
USE_TEST_KEYS=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
@@ -15,6 +16,10 @@ while [[ $# -gt 0 ]]; do
|
||||
PRESERVE_DATABASE=true
|
||||
shift
|
||||
;;
|
||||
--test-keys|-t)
|
||||
USE_TEST_KEYS=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
HELP=true
|
||||
shift
|
||||
@@ -33,6 +38,7 @@ if [ "$HELP" = true ]; then
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --preserve-database, -p Keep existing database files (don't delete for fresh start)"
|
||||
echo " --test-keys, -t Use deterministic test keys for development (admin: all 'a's, relay: all '1's)"
|
||||
echo " --help, -h Show this help message"
|
||||
echo ""
|
||||
echo "Event-Based Configuration:"
|
||||
@@ -43,6 +49,8 @@ if [ "$HELP" = true ]; then
|
||||
echo "Examples:"
|
||||
echo " $0 # Fresh start with new keys (default)"
|
||||
echo " $0 -p # Preserve existing database and keys"
|
||||
echo " $0 -t # Use test keys for consistent development"
|
||||
echo " $0 -t -p # Use test keys and preserve database"
|
||||
echo ""
|
||||
echo "Default behavior: Deletes existing database files to start fresh with new keys"
|
||||
echo " for development purposes"
|
||||
@@ -146,8 +154,14 @@ echo "Debug: Current processes: $(ps aux | grep 'c_relay_' | grep -v grep || ech
|
||||
|
||||
# Change to build directory before starting relay so database files are created there
|
||||
cd build
|
||||
# Start relay in background and capture its PID (no command line arguments needed)
|
||||
./$(basename $BINARY_PATH) > ../relay.log 2>&1 &
|
||||
# Start relay in background and capture its PID
|
||||
if [ "$USE_TEST_KEYS" = true ]; then
|
||||
echo "Using deterministic test keys for development..."
|
||||
./$(basename $BINARY_PATH) -a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -r 1111111111111111111111111111111111111111111111111111111111111111 > ../relay.log 2>&1 &
|
||||
else
|
||||
# No command line arguments needed for random key generation
|
||||
./$(basename $BINARY_PATH) > ../relay.log 2>&1 &
|
||||
fi
|
||||
RELAY_PID=$!
|
||||
# Change back to original directory
|
||||
cd ..
|
||||
@@ -161,7 +175,34 @@ sleep 3
|
||||
if ps -p "$RELAY_PID" >/dev/null 2>&1; then
|
||||
echo "Relay started successfully!"
|
||||
echo "PID: $RELAY_PID"
|
||||
echo "WebSocket endpoint: ws://127.0.0.1:8888"
|
||||
|
||||
# Wait for relay to fully initialize and detect the actual port it's using
|
||||
sleep 2
|
||||
|
||||
# Extract actual port from relay logs
|
||||
ACTUAL_PORT=""
|
||||
if [ -f relay.log ]; then
|
||||
# Look for the success message with actual port
|
||||
ACTUAL_PORT=$(grep "WebSocket relay started on ws://127.0.0.1:" relay.log 2>/dev/null | tail -1 | sed -n 's/.*ws:\/\/127\.0\.0\.1:\([0-9]*\).*/\1/p')
|
||||
|
||||
# If we couldn't find the port in logs, try to detect from netstat
|
||||
if [ -z "$ACTUAL_PORT" ]; then
|
||||
ACTUAL_PORT=$(netstat -tln 2>/dev/null | grep -E ":888[0-9]" | head -1 | sed -n 's/.*:\([0-9]*\).*/\1/p')
|
||||
fi
|
||||
fi
|
||||
|
||||
# Display the actual endpoint
|
||||
if [ -n "$ACTUAL_PORT" ]; then
|
||||
if [ "$ACTUAL_PORT" = "8888" ]; then
|
||||
echo "WebSocket endpoint: ws://127.0.0.1:$ACTUAL_PORT"
|
||||
else
|
||||
echo "WebSocket endpoint: ws://127.0.0.1:$ACTUAL_PORT (fell back from port 8888)"
|
||||
fi
|
||||
else
|
||||
echo "WebSocket endpoint: ws://127.0.0.1:8888 (port detection failed - check logs)"
|
||||
fi
|
||||
|
||||
echo "HTTP endpoint: http://127.0.0.1:${ACTUAL_PORT:-8888}"
|
||||
echo "Log file: relay.log"
|
||||
echo ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user