v0.3.0 - Complete deployment documentation and examples - Added comprehensive deployment guide, automated deployment scripts, nginx SSL proxy setup, backup automation, and monitoring tools. Includes VPS deployment, cloud platform guides, and practical examples for production deployment of event-based configuration system.
This commit is contained in:
@@ -6,13 +6,13 @@
|
||||
echo "=== C Nostr Relay Build and Restart Script ==="
|
||||
|
||||
# Parse command line arguments
|
||||
PRESERVE_CONFIG=false
|
||||
PRESERVE_DATABASE=false
|
||||
HELP=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--preserve-config|-p)
|
||||
PRESERVE_CONFIG=true
|
||||
--preserve-database|-p)
|
||||
PRESERVE_DATABASE=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
@@ -32,44 +32,40 @@ if [ "$HELP" = true ]; then
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --preserve-config, -p Keep existing configuration file (don't regenerate)"
|
||||
echo " --help, -h Show this help message"
|
||||
echo " --preserve-database, -p Keep existing database files (don't delete for fresh start)"
|
||||
echo " --help, -h Show this help message"
|
||||
echo ""
|
||||
echo "Development Setup:"
|
||||
echo " Uses local config directory: ./dev-config/"
|
||||
echo " This avoids conflicts with production instances using ~/.config/c-relay/"
|
||||
echo "Event-Based Configuration:"
|
||||
echo " This relay now uses event-based configuration stored directly in the database."
|
||||
echo " On first startup, keys are automatically generated and printed once."
|
||||
echo " Database file: <relay_pubkey>.nrdb (created automatically)"
|
||||
echo ""
|
||||
echo "Default behavior: Automatically regenerates configuration file on each build"
|
||||
echo "Examples:"
|
||||
echo " $0 # Fresh start with new keys (default)"
|
||||
echo " $0 -p # Preserve existing database and keys"
|
||||
echo ""
|
||||
echo "Default behavior: Deletes existing database files to start fresh with new keys"
|
||||
echo " for development purposes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Handle configuration file and database regeneration
|
||||
# Use local development config directory to avoid conflicts with production
|
||||
DEV_CONFIG_DIR="./dev-config"
|
||||
CONFIG_FILE="$DEV_CONFIG_DIR/c_relay_config_event.json"
|
||||
DB_FILE="./db/c_nostr_relay.db"
|
||||
|
||||
# Create development config directory if it doesn't exist
|
||||
mkdir -p "$DEV_CONFIG_DIR"
|
||||
|
||||
if [ "$PRESERVE_CONFIG" = false ]; then
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
echo "Removing old development configuration file to trigger regeneration..."
|
||||
rm -f "$CONFIG_FILE"
|
||||
echo "✓ Development configuration file removed - will be regenerated with new keys"
|
||||
# Handle database file cleanup for fresh start
|
||||
if [ "$PRESERVE_DATABASE" = false ]; then
|
||||
if ls *.nrdb >/dev/null 2>&1; then
|
||||
echo "Removing existing database files to trigger fresh key generation..."
|
||||
rm -f *.nrdb
|
||||
echo "✓ Database files removed - will generate new keys and database"
|
||||
else
|
||||
echo "No existing database found - will generate fresh setup"
|
||||
fi
|
||||
if [ -f "$DB_FILE" ]; then
|
||||
echo "Removing old database to trigger fresh key generation..."
|
||||
rm -f "$DB_FILE"* # Remove db file and any WAL/SHM files
|
||||
echo "✓ Database removed - will be recreated with embedded schema and new keys"
|
||||
fi
|
||||
elif [ "$PRESERVE_CONFIG" = true ]; then
|
||||
echo "Preserving existing development configuration and database as requested"
|
||||
else
|
||||
echo "No existing development configuration or database found - will generate fresh setup"
|
||||
echo "Preserving existing database files as requested"
|
||||
fi
|
||||
|
||||
# Clean up legacy files that are no longer used
|
||||
rm -rf dev-config/ 2>/dev/null
|
||||
rm -f db/c_nostr_relay.db* 2>/dev/null
|
||||
|
||||
# Build the project first
|
||||
echo "Building project..."
|
||||
make clean all
|
||||
@@ -126,15 +122,15 @@ fi
|
||||
rm -f relay.pid
|
||||
|
||||
# Database initialization is now handled automatically by the relay
|
||||
# when it starts up with embedded schema
|
||||
# with event-based configuration system
|
||||
echo "Database will be initialized automatically on startup if needed"
|
||||
|
||||
# Start relay in background with output redirection
|
||||
echo "Starting relay server..."
|
||||
echo "Debug: Current processes: $(ps aux | grep 'c_relay_' | grep -v grep || echo 'None')"
|
||||
|
||||
# Start relay in background and capture its PID with development config directory
|
||||
$BINARY_PATH --config-dir "$DEV_CONFIG_DIR" > relay.log 2>&1 &
|
||||
# Start relay in background and capture its PID (no command line arguments needed)
|
||||
$BINARY_PATH > relay.log 2>&1 &
|
||||
RELAY_PID=$!
|
||||
|
||||
echo "Started with PID: $RELAY_PID"
|
||||
@@ -155,23 +151,25 @@ if ps -p "$RELAY_PID" >/dev/null 2>&1; then
|
||||
|
||||
# Check if new keys were generated and display them
|
||||
sleep 1 # Give relay time to write initial logs
|
||||
if grep -q "GENERATED RELAY KEYPAIRS" relay.log 2>/dev/null; then
|
||||
echo "=== IMPORTANT: NEW KEYPAIRS GENERATED ==="
|
||||
if grep -q "IMPORTANT: SAVE THIS ADMIN PRIVATE KEY SECURELY!" relay.log 2>/dev/null; then
|
||||
echo "=== IMPORTANT: NEW ADMIN PRIVATE KEY GENERATED ==="
|
||||
echo ""
|
||||
# Extract and display the keypairs section from the log
|
||||
grep -A 12 -B 2 "GENERATED RELAY KEYPAIRS" relay.log | head -n 16
|
||||
# Extract and display the admin private key section from the log
|
||||
grep -A 15 -B 2 "IMPORTANT: SAVE THIS ADMIN PRIVATE KEY SECURELY!" relay.log | head -n 20
|
||||
echo ""
|
||||
echo "⚠️ SAVE THESE PRIVATE KEYS SECURELY - THEY CONTROL YOUR RELAY!"
|
||||
echo "⚠️ These keys are also logged in relay.log for reference"
|
||||
echo "⚠️ SAVE THIS ADMIN PRIVATE KEY SECURELY - IT CONTROLS YOUR RELAY CONFIGURATION!"
|
||||
echo "⚠️ This key is needed to update configuration and is only displayed once"
|
||||
echo "⚠️ The relay and database information is also logged in relay.log for reference"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "=== Relay server running in background ==="
|
||||
echo "Development config: $DEV_CONFIG_DIR/"
|
||||
echo "=== Event-Based Relay Server Running ==="
|
||||
echo "Configuration: Event-based (kind 33334 Nostr events)"
|
||||
echo "Database: Automatically created with relay pubkey naming"
|
||||
echo "To kill relay: pkill -f 'c_relay_'"
|
||||
echo "To check status: ps aux | grep c_relay_"
|
||||
echo "To view logs: tail -f relay.log"
|
||||
echo "Binary: $BINARY_PATH --config-dir $DEV_CONFIG_DIR"
|
||||
echo "Binary: $BINARY_PATH (zero configuration needed)"
|
||||
echo "Ready for Nostr client connections!"
|
||||
else
|
||||
echo "ERROR: Relay failed to start"
|
||||
|
||||
Reference in New Issue
Block a user