feat: Added a way to configure loop delay in seconds

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2022-07-02 00:12:38 +02:00
parent a81caddd33
commit 8bafa49bec
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -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));
}
}