diff --git a/config/default.toml b/config/default.toml index 766bfcd..59f0bf6 100644 --- a/config/default.toml +++ b/config/default.toml @@ -16,6 +16,6 @@ port = 7000 #IP address. Enter 0.0.0.0 to listen on all availale addresses ip= "0.0.0.0" # The number of worker threads that must be spun up by the Pages server. -# Minimum of two threads are advisable for top async performace but can work +# Minimum of two threads are advisable for top async performance but can work # with one also. workers = 2 diff --git a/src/settings.rs b/src/settings.rs index 027369d..1857d0b 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -53,14 +53,24 @@ impl Settings { const CURRENT_DIR: &str = "./config/default.toml"; const ETC: &str = "/etc/static-pages/config.toml"; - if let Ok(path) = env::var("PAGES__CONFIG") { - s = s.add_source(File::with_name(&path)); - } else if Path::new(CURRENT_DIR).exists() { + let mut read_file = false; + + if Path::new(ETC).exists() { + s = s.add_source(File::with_name(ETC)); + read_file = true; + } + if Path::new(CURRENT_DIR).exists() { // merging default config from file s = s.add_source(File::with_name(CURRENT_DIR)); - } else if Path::new(ETC).exists() { - s = s.add_source(File::with_name(ETC)); - } else { + read_file = true; + } + + if let Ok(path) = env::var("PAGES_CONFIG") { + s = s.add_source(File::with_name(&path)); + read_file = true; + } + + if !read_file { log::warn!("configuration file not found"); }