Skip to content

Commit

Permalink
node start will not panic when child process crashed
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Aug 2, 2023
1 parent 3ef18d9 commit 5673983
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lazy_static = "1.4.0"
byteorder = "1.3.1"
jsonrpc-core = "18.0"
ctrlc = { version = "3.1", features = ["termination"] }
log = "0.4"

[target.'cfg(not(target_os="windows"))'.dependencies]
nix = { version = "0.24.0", default-features = false, features = ["signal"] }
Expand Down
3 changes: 1 addition & 2 deletions test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ fn main() {
for name in cloned_running_names.lock().iter() {
warn!("spec {} is still not finished", name);
}
// sleep 1 second to wait for the log flush
std::thread::sleep(Duration::from_secs(1));
log::logger().flush();
std::process::exit(1);
})
.expect("Error setting Ctrl-C handler");
Expand Down
7 changes: 4 additions & 3 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::collections::HashSet;
use std::convert::Into;
use std::fs;
use std::path::PathBuf;
use std::process::{self, Child, Command, Stdio};
use std::process::{Child, Command, Stdio};
use std::thread::sleep;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -609,15 +609,16 @@ impl Node {
status,
self.log_path().display()
);
process::exit(status.code().unwrap());
// parent process will exit
return;
}
Err(error) => {
error!(
"Error: node crashed with reason: {}, log_path: {}",
error,
self.log_path().display()
);
process::exit(255);
return;
}
}
};
Expand Down

0 comments on commit 5673983

Please sign in to comment.