From 8bafa49becf5e160582c33c3259a4ee6e3e06e03 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sat, 2 Jul 2022 00:12:38 +0200 Subject: [PATCH] feat: Added a way to configure loop delay in seconds Signed-off-by: Louis Vallat --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b77b21a..aaf5104 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,8 @@ async fn main() { .expect("Environment variable 'ROUTER_PASSWORD' not set."); let hostname = std::env::var("HOSTNAME") .expect("Environment variable 'HOSTNAME' not set."); + let loop_delay = std::env::var("LOOP_DELAY") + .expect("Environment variable 'LOOP_DELAY' not set.").parse().unwrap_or(60); let i_client = influxdb2::Client::new(host, org, token); @@ -56,8 +58,9 @@ async fn main() { i_client.write(bucket.as_str(), stream::iter(datapoints)).await .unwrap(); debug!("Datapoints sent. Took {:.2?}.", now.elapsed()); - info!("End of loop. Took {:.2?}. Waiting for 60 seconds.", start.elapsed()); - std::thread::sleep(Duration::from_secs(5)); + info!("End of loop. Took {:.2?}. Waiting for {} seconds.", + start.elapsed(), loop_delay); + std::thread::sleep(Duration::from_secs(loop_delay)); } }