v0.2.16 - fixed config bugs

This commit is contained in:
Your Name
2025-09-06 10:24:42 -04:00
parent 580aec7d57
commit 342defca6b
8 changed files with 16 additions and 12 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ Trash/
src/version.h src/version.h
dev-config/ dev-config/
db/ db/
copy_executable_local.sh

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
943745 949770

View File

@@ -577,12 +577,20 @@ const char* get_config_value(const char* key) {
return NULL; 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) { if (get_database_config(key, buffer, sizeof(buffer)) == 0) {
return buffer; return buffer;
} }
// Priority 2: Environment variables (fallback) // Priority 3: Environment variables (fallback)
const char* env_value = getenv(key); const char* env_value = getenv(key);
if (env_value) { if (env_value) {
return env_value; return env_value;

View File

@@ -3113,12 +3113,8 @@ int main(int argc, char* argv[]) {
return 1; return 1;
} }
// Store database path override in configuration if specified // Database path override is applied via environment variable - no need to store in config
if (database_path_override) { // (storing database path in database creates circular dependency)
if (set_database_config("database_path", database_path_override, "command_line") != 0) {
log_warning("Failed to store database path override in configuration");
}
}
// Initialize nostr library BEFORE configuration system // Initialize nostr library BEFORE configuration system
// (required for Nostr event generation in config files) // (required for Nostr event generation in config files)
@@ -3140,11 +3136,10 @@ int main(int argc, char* argv[]) {
if (port != DEFAULT_PORT) { if (port != DEFAULT_PORT) {
log_info("Applying port override from command line"); log_info("Applying port override from command line");
printf(" Port: %d\n", port); printf(" Port: %d\n", port);
// Set environment variable for port override (runtime only, not persisted)
char port_str[16]; char port_str[16];
snprintf(port_str, sizeof(port_str), "%d", port); snprintf(port_str, sizeof(port_str), "%d", port);
if (set_database_config("relay_port", port_str, "command_line") != 0) { setenv("C_RELAY_PORT_OVERRIDE", port_str, 1);
log_warning("Failed to set port override in configuration");
}
} }
// Initialize NIP-11 relay information // Initialize NIP-11 relay information

BIN
test_check.db Normal file

Binary file not shown.