add showing system running time

This commit is contained in:
Y. T. Chung
2016-07-09 00:48:39 +08:00
parent fab4d36cee
commit 98f786f1c7
+13
View File
@@ -37,6 +37,7 @@ extern crate coio;
extern crate env_logger;
use std::env;
use std::time::Duration;
use clap::{App, Arg};
@@ -44,6 +45,7 @@ use coio::Scheduler;
use env_logger::LogBuilder;
use log::{LogRecord, LogLevelFilter};
use time::PreciseTime;
use shadowsocks::config::{self, Config, ServerConfig};
use shadowsocks::config::DEFAULT_DNS_CACHE_CAPACITY;
@@ -275,10 +277,21 @@ fn main() {
.ok()
.expect("`threads` should be an integer");
let show_run_time = matches.occurrences_of("VERBOSE") >= 2;
Scheduler::new()
.with_workers(threads)
.default_stack_size(128 * 1024)
.run(move || {
if show_run_time {
let start_time = PreciseTime::now();
Scheduler::spawn(move|| {
loop {
info!("SYSTEM System has already run {}", start_time.to(PreciseTime::now()));
coio::sleep(Duration::from_secs(5));
}
});
}
RelayServer::new(config).run();
})
.unwrap();