implement env variable

This commit is contained in:
jim-taylor-business 2024-04-05 08:02:48 +01:00
parent dc1494bbdc
commit c1e5e48184

View file

@ -12,7 +12,18 @@ use structs::{DatabaseConnection, PictrsConfig, PictrsImageMode, Settings};
static DEFAULT_CONFIG_FILE: &str = "config/config.hjson";
pub static SETTINGS: Lazy<Settings> = Lazy::new(|| Settings::init().unwrap_or_default());
pub static SETTINGS: Lazy<Settings> = Lazy::new(|| {
if let Ok(value) = env::var("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS") {
if value.eq("true") {
println!("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS was set to `true`, any configuration file has been ignored");
println!("Use with other environment variables to configure this instance further, e.g. LEMMY_DATABASE_URL");
return Settings::default();
}
}
Settings::init().expect("Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html)")
});
// pub static SETTINGS: Lazy<Settings> = Lazy::new(|| Settings::init().unwrap_or_default());
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(&format!(