From ebbaed09737527ed78af1297359d435e0aa4efb4 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sun, 17 Sep 2023 20:11:06 +0200 Subject: [PATCH] Reduce load by not constantly spawning new threads for sleeping --- src/main.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 707754c..239a703 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,9 +86,6 @@ async fn postgres_watchdog(pool: PgPool, is_alive: Arc, shutdown: Ar println!("No Uptime Kuma URL provided!"); } - - let passed = (Local::now() - start).to_std().expect(&format!("Unable to get Time Difference for '{}' and '{}'", start, Local::now())); - while Local::now() - start < chrono::Duration::seconds(15) { sleep(Duration::from_millis(100)).await; if shutdown.load(Ordering::Relaxed) { @@ -296,11 +293,7 @@ async fn main() -> Result<()> { //watchdog_thread.await; while is_alive.load(Ordering::Relaxed) { - let thread = tokio::spawn(async { - let _ = sleep(Duration::from_millis(100)); - }); - - let _ = thread.await; + sleep(Duration::from_millis(200)).await; } if shutdown.load(Ordering::Relaxed) {