Skip to content

Instantly share code, notes, and snippets.

@gilbertw1
Created March 30, 2022 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilbertw1/798bdfb87d760c9fb0969abc99a52573 to your computer and use it in GitHub Desktop.
Save gilbertw1/798bdfb87d760c9fb0969abc99a52573 to your computer and use it in GitHub Desktop.
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