Configurable Update Interval. Closes #29
All checks were successful
Run Tests on Code / run-tests (push) Successful in 15s
All checks were successful
Run Tests on Code / run-tests (push) Successful in 15s
This commit is contained in:
parent
3639511414
commit
33f36adf3f
1 changed files with 21 additions and 2 deletions
23
src/main.rs
23
src/main.rs
|
@ -1,6 +1,6 @@
|
|||
/*use cloudflare_old::{Instance, CloudflareDnsType};*/
|
||||
use reqwest::blocking::get;
|
||||
use std::{thread::{sleep}};
|
||||
use std::{env, thread::{sleep}};
|
||||
use std::error::Error;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::str::FromStr;
|
||||
|
@ -248,9 +248,28 @@ fn main() {
|
|||
Err(e) => panic!("{}", e)
|
||||
};
|
||||
|
||||
let reload_interval = match env::var("RELOAD_INTERVAL_SECONDS") {
|
||||
Ok(interval_string) => i64::from_str(&interval_string).unwrap_or_else(|e| {
|
||||
let warn_msg = format!("Expected integer number, got '{interval_string}'. Defaulting to 60");
|
||||
match connected_to_journal() {
|
||||
true => warn!("[WARN] {warn_msg}"),
|
||||
false => println!("[WARN] {warn_msg}"),
|
||||
};
|
||||
60
|
||||
}),
|
||||
Err(_) => {
|
||||
let warn_msg = "Reload interval env not set, defaulting to 60";
|
||||
match connected_to_journal() {
|
||||
true => warn!("[WARN] {warn_msg}"),
|
||||
false => println!("[WARN] {warn_msg}"),
|
||||
}
|
||||
60
|
||||
},
|
||||
};
|
||||
|
||||
loop {
|
||||
now = Utc::now();
|
||||
if now >= start + Duration::seconds(10) { // DEBUG was 60
|
||||
if now >= start + Duration::seconds(reload_interval) { // DEBUG was 60
|
||||
start = now;
|
||||
|
||||
match InterfaceConfig::load() {
|
||||
|
|
Loading…
Reference in a new issue