mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 11:51:08 +00:00
Parameterize config file location
Allows `config.hjson` to be located on a configurable path.
This commit is contained in:
parent
fc36ae22c9
commit
bfd8f52497
1 changed files with 7 additions and 3 deletions
|
@ -93,7 +93,7 @@ impl Settings {
|
||||||
|
|
||||||
s.merge(File::with_name(&Self::get_config_defaults_location()))?;
|
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)
|
// Add in settings from the environment (with a prefix of LEMMY)
|
||||||
// Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key
|
// Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key
|
||||||
|
@ -122,11 +122,15 @@ impl Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_defaults_location() -> String {
|
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<String, Error> {
|
pub fn read_config_file() -> Result<String, Error> {
|
||||||
fs::read_to_string(CONFIG_FILE)
|
fs::read_to_string(Self::get_config_location())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_allowed_instances(&self) -> Vec<String> {
|
pub fn get_allowed_instances(&self) -> Vec<String> {
|
||||||
|
|
Loading…
Reference in a new issue