Created
March 30, 2022 16:18
-
-
Save gilbertw1/798bdfb87d760c9fb0969abc99a52573 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::{SystemTime, UNIX_EPOCH}; | |
mod cli; | |
mod conf; | |
mod sync; | |
extern crate clap; | |
extern crate eventual; | |
fn main() { | |
let config = conf::WeatherlandConfig::load(); | |
if config.debug { | |
println!("[main] config: {:?}", config); | |
} | |
let mut last: u64 = 0; | |
loop { | |
let new_result = sync::job(&config); | |
if new_result.is_ok() { | |
let new = new_result.unwrap(); | |
let diff = (new - last) / 60; | |
if config.debug { | |
println!("[main] last: {}; now: {}; diff: {}", last, now, diff); | |
} | |
last = new; | |
std::thread::sleep(config.poll_time * 1000); | |
} else if new_result.is_err() { | |
// log error | |
std::thread::sleep(config.retry_time * 1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment