aquatic_http, aquatic_ws: add option for printing statistics

statistics are on number of peers per torrent
This commit is contained in:
Joakim Frostegård 2020-08-13 03:58:28 +02:00
parent 23a562c1e5
commit 88423976c4
9 changed files with 150 additions and 1 deletions

View file

@ -127,6 +127,21 @@ pub fn start_workers(config: Config, state: State) -> anyhow::Result<()> {
})?;
}
if config.statistics.interval != 0 {
let state = state.clone();
let config = config.clone();
Builder::new().name("statistics".to_string()).spawn(move ||
loop {
::std::thread::sleep(Duration::from_secs(
config.statistics.interval
));
tasks::print_statistics(&state);
}
).expect("spawn statistics thread");
}
Ok(())
}