|
|
|
@ -13,8 +13,17 @@ use structs::{DatabaseConnection, PictrsConfig, PictrsImageMode, Settings};
|
|
|
|
|
static DEFAULT_CONFIG_FILE: &str = "config/config.hjson";
|
|
|
|
|
|
|
|
|
|
pub static SETTINGS: Lazy<Settings> = Lazy::new(|| {
|
|
|
|
|
Settings::init().expect("Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html)")
|
|
|
|
|
if env::var("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS").is_ok() {
|
|
|
|
|
println!(
|
|
|
|
|
"LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS was set, any configuration file has been ignored."
|
|
|
|
|
);
|
|
|
|
|
println!("Use with other environment variables to configure this instance further; e.g. LEMMY_DATABASE_URL.");
|
|
|
|
|
Settings::default()
|
|
|
|
|
} else {
|
|
|
|
|
Settings::init().expect("Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html).")
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| {
|
|
|
|
|
Regex::new(&format!(
|
|
|
|
|
"^acct:([a-zA-Z0-9_]{{3,}})@{}$",
|
|
|
|
@ -30,9 +39,7 @@ impl Settings {
|
|
|
|
|
/// `lemmy_db_schema/src/lib.rs::get_database_url_from_env()`
|
|
|
|
|
/// Warning: Only call this once.
|
|
|
|
|
pub(crate) fn init() -> Result<Self, LemmyError> {
|
|
|
|
|
// Read the config file
|
|
|
|
|
let config = from_str::<Settings>(&Self::read_config_file()?)?;
|
|
|
|
|
|
|
|
|
|
if config.hostname == "unset" {
|
|
|
|
|
Err(anyhow!("Hostname variable is not set!").into())
|
|
|
|
|
} else {
|
|
|
|
|