diff --git a/rust/scx_utils/src/misc.rs b/rust/scx_utils/src/misc.rs index a52fbeda5..0d173a2de 100644 --- a/rust/scx_utils/src/misc.rs +++ b/rust/scx_utils/src/misc.rs @@ -1,7 +1,7 @@ use anyhow::bail; use anyhow::Result; use libc; -use log::info; +use log::{info, warn}; use scx_stats::prelude::*; use serde::Deserialize; use std::path::Path; @@ -30,7 +30,7 @@ where Err(e) => match e.downcast_ref::() { Some(ioe) if RETRYABLE_ERRORS.contains(&ioe.kind()) => { if retry_cnt == 1 { - info!("Stats server not avaliable, retrying..."); + info!("Stats server not available, retrying..."); } retry_cnt += 1; sleep(Duration::from_secs(1)); @@ -50,7 +50,11 @@ where sleep(Duration::from_secs(1)); break; } - None => Err(e)?, + None => { + warn!("error on handling stats_server result {}", &e); + sleep(Duration::from_secs(1)); + break; + } }, }; output(stats)?; diff --git a/scheds/rust/scx_bpfland/src/main.rs b/scheds/rust/scx_bpfland/src/main.rs index b0ae10797..9a7eb04a3 100644 --- a/scheds/rust/scx_bpfland/src/main.rs +++ b/scheds/rust/scx_bpfland/src/main.rs @@ -31,8 +31,8 @@ use libbpf_rs::skel::Skel; use libbpf_rs::skel::SkelBuilder; use libbpf_rs::OpenObject; use libbpf_rs::ProgramInput; -use log::info; use log::warn; +use log::{debug, info}; use scx_stats::prelude::*; use scx_utils::build_id; use scx_utils::import_enums; @@ -612,7 +612,17 @@ fn main() -> Result<()> { if let Some(intv) = opts.monitor.or(opts.stats) { let shutdown_copy = shutdown.clone(); let jh = std::thread::spawn(move || { - stats::monitor(Duration::from_secs_f64(intv), shutdown_copy).unwrap() + match stats::monitor(Duration::from_secs_f64(intv), shutdown_copy) { + Ok(_) => { + debug!("stats monitor thread finished successfully") + } + Err(error_object) => { + warn!( + "stats monitor thread finished because of an error {}", + error_object + ) + } + } }); if opts.monitor.is_some() { let _ = jh.join(); diff --git a/scheds/rust/scx_layered/src/main.rs b/scheds/rust/scx_layered/src/main.rs index e8b6d3bf7..9bca9d5d6 100644 --- a/scheds/rust/scx_layered/src/main.rs +++ b/scheds/rust/scx_layered/src/main.rs @@ -2288,7 +2288,17 @@ fn main() -> Result<()> { if let Some(intv) = opts.monitor.or(opts.stats) { let shutdown_copy = shutdown.clone(); let jh = std::thread::spawn(move || { - stats::monitor(Duration::from_secs_f64(intv), shutdown_copy).unwrap() + match stats::monitor(Duration::from_secs_f64(intv), shutdown_copy) { + Ok(_) => { + debug!("stats monitor thread finished successfully") + } + Err(error_object) => { + warn!( + "stats monitor thread finished because of an error {}", + error_object + ) + } + } }); if opts.monitor.is_some() { let _ = jh.join();