From b8e62cde7560d24ee5efd19df7dda0e6a7b0f646 Mon Sep 17 00:00:00 2001 From: Tie Liu Date: Wed, 21 Jun 2023 17:33:46 +0800 Subject: [PATCH 1/2] diff arm and x86 for test process config --- bin/daemon.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/daemon.rs b/bin/daemon.rs index 015fb82..7d360a7 100644 --- a/bin/daemon.rs +++ b/bin/daemon.rs @@ -582,6 +582,7 @@ mod tests { } #[test] + #[cfg(target_arch = "aarch64")] fn test_process_config() { // Create a temporary directory for testing let temp_dir = tempfile::tempdir().unwrap(); -- Gitee From c822aa321cb30d2d00d5ff2dbfdf687cf4eb0168 Mon Sep 17 00:00:00 2001 From: Tie Liu Date: Wed, 21 Jun 2023 17:36:17 +0800 Subject: [PATCH 2/2] watch old config --- bin/daemon.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bin/daemon.rs b/bin/daemon.rs index 7d360a7..405826f 100644 --- a/bin/daemon.rs +++ b/bin/daemon.rs @@ -482,6 +482,28 @@ fn check_elf_files_modify(inotify: &mut Inotify) -> bool { return false; } +fn watch_old_config_files() -> Inotify { + // read configs /etc/sysboost.d, like bash.toml + let dir_e = fs::read_dir(&Path::new("/etc/sysboost.d")); + let dir = match dir_e { + Ok(dir) => dir, + Err(e) => { + log::error!("{}", e); + return; + } + }; + let mut inotify = Inotify::init().expect("Failed to init inotify."); + for entry in dir { + let file_path = Path::new(entry); + match inotify.add_watch(file_path, WatchMask::MODIFY) { + Ok(_) => {} + Err(e) => { + log::error!("watch config fail {}", e); + } + }; + } +} + fn start_service() { set_ko_rto_flag(false); clean_last_rto(); @@ -490,6 +512,7 @@ fn start_service() { refresh_all_config(&mut rto_configs); let mut elf_inotify = watch_old_elf_files(&rto_configs); + let mut conf_inotify = watch_old_config_files(); loop { // wait some time -- Gitee