Skip to content

Commit

Permalink
fix: mercury server build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Apr 18, 2024
1 parent 77ec346 commit eae1e4d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/src/server_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ impl ServerConfig {
// Override with settings in file Rocket.toml if exists
conf_rs.merge(File::with_name("Rocket").required(false));

let settings = ConfigRs::builder()
.add_source(File::with_name("Settings"))
.build()
.unwrap();

// Function to fetch a setting from the environment or fallback to the config file
let get_env_or_config = |key: &str, env_var: &str| -> String {
env::var(env_var).unwrap_or_else(|_| settings.get_string(key).unwrap())
Expand All @@ -63,7 +68,7 @@ impl ServerConfig {
lockheight_init: get_env_or_config("lockheight_init", "LOCKHEIGHT_INIT").parse::<u32>().unwrap(),
lh_decrement: get_env_or_config("lh_decrement", "LH_DECREMENT").parse::<u32>().unwrap(),
connection_string: get_env_or_config("connection_string", "DATABASE_CONNECTION_STRING"),
}
};
conf_rs.try_into().unwrap()
}
}

0 comments on commit eae1e4d

Please sign in to comment.