diff options
author | metamuffin <metamuffin@disroot.org> | 2023-11-20 11:25:50 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-11-20 11:25:50 +0100 |
commit | bcc135761db881fd937767788a0d0480bb1b1f31 (patch) | |
tree | 90d2ba4ad48ae6ea4c3a545753696a6414fe891c /src/main.rs | |
parent | cd8dca8cd323347a96a6f9c31e7465377e6230d3 (diff) | |
download | gnix-bcc135761db881fd937767788a0d0480bb1b1f31.tar gnix-bcc135761db881fd937767788a0d0480bb1b1f31.tar.bz2 gnix-bcc135761db881fd937767788a0d0480bb1b1f31.tar.zst |
fix file watch path
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(); |