diff --git a/.gitignore b/.gitignore index 6c452ba..b81ce24 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ Trash/ src/version.h dev-config/ db/ +copy_executable_local.sh diff --git a/db/c_nostr_relay.db b/db/c_nostr_relay.db index 119ced1..a42a536 100644 Binary files a/db/c_nostr_relay.db and b/db/c_nostr_relay.db differ diff --git a/db/c_nostr_relay.db-shm b/db/c_nostr_relay.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/db/c_nostr_relay.db-shm and /dev/null differ diff --git a/db/c_nostr_relay.db-wal b/db/c_nostr_relay.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/relay.pid b/relay.pid index 3895e14..13e1251 100644 --- a/relay.pid +++ b/relay.pid @@ -1 +1 @@ -943745 +949770 diff --git a/src/config.c b/src/config.c index 18b59c6..e872ff8 100644 --- a/src/config.c +++ b/src/config.c @@ -577,12 +577,20 @@ const char* get_config_value(const char* key) { return NULL; } - // Priority 1: Database configuration (updated from file) + // Priority 1: Command line overrides via environment variables + if (strcmp(key, "relay_port") == 0) { + const char* port_override = getenv("C_RELAY_PORT_OVERRIDE"); + if (port_override) { + return port_override; + } + } + + // Priority 2: Database configuration (updated from file) if (get_database_config(key, buffer, sizeof(buffer)) == 0) { return buffer; } - // Priority 2: Environment variables (fallback) + // Priority 3: Environment variables (fallback) const char* env_value = getenv(key); if (env_value) { return env_value; diff --git a/src/main.c b/src/main.c index 7c07d54..a287d02 100644 --- a/src/main.c +++ b/src/main.c @@ -3113,12 +3113,8 @@ int main(int argc, char* argv[]) { return 1; } - // Store database path override in configuration if specified - if (database_path_override) { - if (set_database_config("database_path", database_path_override, "command_line") != 0) { - log_warning("Failed to store database path override in configuration"); - } - } + // Database path override is applied via environment variable - no need to store in config + // (storing database path in database creates circular dependency) // Initialize nostr library BEFORE configuration system // (required for Nostr event generation in config files) @@ -3140,11 +3136,10 @@ int main(int argc, char* argv[]) { if (port != DEFAULT_PORT) { log_info("Applying port override from command line"); printf(" Port: %d\n", port); + // Set environment variable for port override (runtime only, not persisted) char port_str[16]; snprintf(port_str, sizeof(port_str), "%d", port); - if (set_database_config("relay_port", port_str, "command_line") != 0) { - log_warning("Failed to set port override in configuration"); - } + setenv("C_RELAY_PORT_OVERRIDE", port_str, 1); } // Initialize NIP-11 relay information diff --git a/test_check.db b/test_check.db new file mode 100644 index 0000000..93511fa Binary files /dev/null and b/test_check.db differ