From: Kenneth Koski Date: Sat, 31 Oct 2020 21:25:15 +0000 (-0500) Subject: Parameterize config file location X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7BelementUrl%7D?a=commitdiff_plain;h=bfd8f52497ced3e252a240f61f9ecb53258702ec;p=lemmy.git Parameterize config file location Allows `config.hjson` to be located on a configurable path. --- diff --git a/lemmy_utils/src/settings.rs b/lemmy_utils/src/settings.rs index 797c6fba..476b7697 100644 --- a/lemmy_utils/src/settings.rs +++ b/lemmy_utils/src/settings.rs @@ -93,7 +93,7 @@ impl Settings { s.merge(File::with_name(&Self::get_config_defaults_location()))?; - s.merge(File::with_name(CONFIG_FILE).required(false))?; + s.merge(File::with_name(&Self::get_config_location()).required(false))?; // Add in settings from the environment (with a prefix of LEMMY) // Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key @@ -122,11 +122,15 @@ impl Settings { } pub fn get_config_defaults_location() -> String { - env::var("LEMMY_CONFIG_LOCATION").unwrap_or_else(|_| CONFIG_FILE_DEFAULTS.to_string()) + env::var("LEMMY_CONFIG_DEFAULTS_LOCATION").unwrap_or_else(|_| CONFIG_FILE_DEFAULTS.to_string()) + } + + pub fn get_config_location() -> String { + env::var("LEMMY_CONFIG_LOCATION").unwrap_or_else(|_| CONFIG_FILE.to_string()) } pub fn read_config_file() -> Result { - fs::read_to_string(CONFIG_FILE) + fs::read_to_string(Self::get_config_location()) } pub fn get_allowed_instances(&self) -> Vec {