diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index d11bfe1..807d0ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,13 @@ use log::{debug, error, info, warn}; #[cfg(feature = "mond")] use reporting::Reporting; use std::{ - fs::File, io::BufReader, net::SocketAddr, ops::ControlFlow, path::Path, process::exit, + fs::File, + io::BufReader, + net::SocketAddr, + ops::ControlFlow, + path::{Path, PathBuf}, + process::exit, + str::FromStr, sync::Arc, }; use tokio::{ @@ -65,6 +71,10 @@ async fn main() -> anyhow::Result<()> { eprintln!("error: first argument is expected to be the configuration file"); exit(1) }; + let config_path = PathBuf::from_str(&config_path) + .unwrap() + .canonicalize() + .unwrap(); let config = match Config::load(&config_path) { Ok(c) => c, @@ -81,7 +91,9 @@ async fn main() -> anyhow::Result<()> { config: RwLock::new(Arc::new(config)), }); - setup_file_watch(config_path.to_owned(), state.clone()); + if state.config.read().await.watch_config { + setup_file_watch(config_path, state.clone()); + } { let state = state.clone(); |