running parallel tokio tasks for heartbeat and metrics

This commit is contained in:
2025-08-09 22:00:42 +02:00
parent a1bbbedd75
commit ac2fce75a0
7 changed files with 93 additions and 28 deletions

View File

@@ -11,7 +11,7 @@ pub struct CpuInfo {
pub current_temp: Option<f64>,
}
pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error>> {
pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error + Send + Sync>> {
let mut sys = System::new();
sys.refresh_cpu_all();
@@ -28,13 +28,13 @@ pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error>> {
})
}
pub async fn get_cpu_load(sys: &mut System) -> Result<f64, Box<dyn Error>> {
pub async fn get_cpu_load(sys: &mut System) -> Result<f64, Box<dyn Error + Send + Sync>> {
sys.refresh_cpu_all();
tokio::task::yield_now().await; // Allow other tasks to run
Ok(sys.global_cpu_usage() as f64)
}
pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error + Send + Sync>> {
println!("Attempting to get CPU temperature...");
#[cfg(target_os = "linux")]