style: code style
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -113,10 +113,10 @@ fn keep_runningd(keep_running_config: Arc<KeepRunningConfig>) {
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let mut fail_count = 0;
|
||||
let check_success = !check_lines.is_empty();
|
||||
{ // limit `CHECK_FAIL_MAP` lock scope
|
||||
let cloned_title = keep_running_config_item.title.clone();
|
||||
let mut check_fail_map = CHECK_FAIL_MAP.lock().unwrap();
|
||||
let check_success = !check_lines.is_empty();
|
||||
if check_success {
|
||||
check_fail_map.insert(cloned_title, 0);
|
||||
} else {
|
||||
@@ -127,7 +127,7 @@ fn keep_runningd(keep_running_config: Arc<KeepRunningConfig>) {
|
||||
}
|
||||
}
|
||||
|
||||
if check_lines.is_empty() { // if check fail!
|
||||
if !check_success { // if check fail!
|
||||
info!("Send DingTalk notification!");
|
||||
block_send_notify(&keep_running_config.notify_token, &keep_running_config_item.title, fail_count);
|
||||
match &keep_running_config_item.restart_command {
|
||||
@@ -152,10 +152,8 @@ fn block_send_notify(notify_token: &str, title: &str, fail_count: u64) {
|
||||
match runtime::Builder::new().basic_scheduler().enable_all().build() {
|
||||
Err(err) => error!("Prepare tokio runtime error: {}", err),
|
||||
Ok(mut rt) => {
|
||||
let mut sb = String::with_capacity(1024);
|
||||
sb.push_str(&format!("Check failed: {}, fail count: {}", title, fail_count));
|
||||
sb.push_str(&format!("\ncheck time: {:?}", Local::now()));
|
||||
rt.block_on(send_notify(notify_token, &sb));
|
||||
let text = format!("Check failed: {}, fail count: {}\ncheck time: {:?}", title, fail_count, Local::now());
|
||||
rt.block_on(send_notify(notify_token, &text));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user