diff --git a/src/services/scheduler.rs b/src/services/scheduler.rs index ba4eb21..662b696 100644 --- a/src/services/scheduler.rs +++ b/src/services/scheduler.rs @@ -6,39 +6,13 @@ use std::str::FromStr; use std::time::Duration; use tokio::time::{sleep_until, Instant as TokioInstant}; -#[cfg(feature = "server")] -pub async fn next_run(schedule: Schedule) { - // Example cron schedule: Every minute - //print next 5 scheduled times - let mut i = 0; - for datetime in schedule.upcoming(chrono::Utc) { - if i < 5 { - println!("Next scheduled time: {}", datetime); - i += 1; - } else { - break; - } - } - let now = chrono::Utc::now(); - if let Some(next) = schedule.upcoming(chrono::Utc).next() { - let duration_until_next = (next - now).to_std().expect("Failed to calculate duration"); - println!("Next scheduled time: {:?}", next); - // Convert std::time::Instant to tokio::time::Instant - refresh_all_workloads().await; - } -} #[cfg(feature = "server")] pub async fn scheduler(schedule: &Schedule) { - // Example cron schedule: Every minute log::info!("Scheduler started"); - //let schedule_str = "0 * * * * *"; // Adjust the cron expression as needed - //let schedule = Schedule::from_str(schedule_str).expect("Failed to parse cron expression"); println!("Cron schedule: {}", schedule); log::info!("Cron schedule: {}", schedule); - // Find the next scheduled time - //print next 5 scheduled times let mut i = 0; for datetime in schedule.upcoming(chrono::Utc) { if i < 5 {