diff --git a/src/main.c b/src/main.c index df78133..7c07d54 100644 --- a/src/main.c +++ b/src/main.c @@ -3052,12 +3052,7 @@ int main(int argc, char* argv[]) { log_error("Invalid port number"); return 1; } - // Store port in configuration system - char port_str[16]; - snprintf(port_str, sizeof(port_str), "%d", port); - set_database_config("relay_port", port_str, "command_line"); - // Re-apply configuration to make sure global variables are updated - apply_configuration_to_globals(); + // Port will be stored in configuration system after it's initialized } else { log_error("Port argument requires a value"); return 1; @@ -3141,6 +3136,17 @@ int main(int argc, char* argv[]) { return 1; } + // Apply command line overrides AFTER configuration system is initialized + if (port != DEFAULT_PORT) { + log_info("Applying port override from command line"); + printf(" Port: %d\n", port); + 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"); + } + } + // Initialize NIP-11 relay information init_relay_info(); diff --git a/test_combined.db b/test_combined.db new file mode 100644 index 0000000..b6477f1 Binary files /dev/null and b/test_combined.db differ