|
@@ -3,7 +3,7 @@
|
|
|
extern crate serde_derive;
|
|
|
#[macro_use]
|
|
|
extern crate rocket;
|
|
|
-#[macro_use]
|
|
|
+// #[macro_use]
|
|
|
extern crate rocket_contrib;
|
|
|
#[macro_use]
|
|
|
extern crate lazy_static;
|
|
@@ -31,9 +31,9 @@ lazy_static! {
|
|
|
}
|
|
|
|
|
|
|
|
|
-fn daemon() {
|
|
|
+fn daemon(interval: u64) {
|
|
|
loop {
|
|
|
- info!(">>> UPD");
|
|
|
+ debug!(">>> UPD");
|
|
|
|
|
|
let accounts_unlocked = ACCOUNTS.lock().unwrap();
|
|
|
let accounts_cl = accounts_unlocked.clone();
|
|
@@ -50,7 +50,7 @@ fn daemon() {
|
|
|
for (account_name, account) in accounts_cl {
|
|
|
let client = client.clone();
|
|
|
let t = thread::spawn(move || {
|
|
|
- info!("ACCT {}", account_name);
|
|
|
+ debug!("ACCT {}", account_name);
|
|
|
|
|
|
let updated_account = account.updated(&client);
|
|
|
let mut accounts = ACCOUNTS.lock().unwrap();
|
|
@@ -71,8 +71,8 @@ fn daemon() {
|
|
|
serde_json::to_writer_pretty(writer, &*accounts_unlocked).unwrap();
|
|
|
drop(accounts_unlocked);
|
|
|
|
|
|
- info!("<<< Cycle over, sleeping 30 secs.");
|
|
|
- let pause = time::Duration::from_secs(30);
|
|
|
+ info!("Waiting {} secs for next update", interval);
|
|
|
+ let pause = time::Duration::from_secs(interval);
|
|
|
thread::sleep(pause);
|
|
|
|
|
|
}
|
|
@@ -88,20 +88,25 @@ fn main() {
|
|
|
match serde_json::from_reader::<_, HashMap<String, Account>>(BufReader::new(f)) {
|
|
|
Ok(accounts) => {
|
|
|
{
|
|
|
+ info!("ACCOUNT DATA LOADED");
|
|
|
// Lock once, shove loaded ccounts in
|
|
|
let mut accounts_unlocked = ACCOUNTS.lock().unwrap();
|
|
|
*accounts_unlocked = accounts;
|
|
|
}
|
|
|
+ info!("START DAEMON");
|
|
|
+
|
|
|
// start daemon before running web server
|
|
|
+ info!("START WEBSERVER");
|
|
|
+
|
|
|
thread::spawn(move || {
|
|
|
- daemon();
|
|
|
+ daemon(200);
|
|
|
});
|
|
|
// run server
|
|
|
server::run();
|
|
|
},
|
|
|
- Err(e) => println!("Parsing account da'a has failed: {:?}", e)
|
|
|
+ Err(e) => error!("Parsing account da'a has failed: {:?}", e)
|
|
|
}
|
|
|
}
|
|
|
- Err(e) => println!("Opening accounts file failed. {:?}", e),
|
|
|
+ Err(e) => error!("Opening accounts file failed. {:?}", e),
|
|
|
}
|
|
|
}
|