mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-04 06:13:09 +00:00
Share lifecycle helpers for node processes
This commit is contained in:
parent
f6e6244226
commit
4daf3e3e12
@ -0,0 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::process::Child;
|
||||
|
||||
/// Shared cleanup helpers for child processes.
|
||||
pub fn kill_child(child: &mut Child) {
|
||||
let _ = child.kill();
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::process::Child;
|
||||
|
||||
/// Shared lifecycle hooks (placeholder).
|
||||
pub fn kill_child(child: &mut Child) {
|
||||
let _ = child.kill();
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
pub mod cleanup;
|
||||
pub mod kill;
|
||||
pub mod monitor;
|
||||
pub mod spawn;
|
||||
|
||||
@ -1,4 +1,11 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared monitoring helpers (placeholder).
|
||||
pub struct Monitor;
|
||||
use std::process::Child;
|
||||
|
||||
/// Check if a child process is still running.
|
||||
pub fn is_running(child: &mut Child) -> bool {
|
||||
match child.try_wait() {
|
||||
Ok(None) => true,
|
||||
Ok(Some(_)) | Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ use crate::{
|
||||
common::{
|
||||
binary::{BinaryConfig, BinaryResolver},
|
||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
||||
lifecycle::kill::kill_child,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -62,9 +63,7 @@ impl Drop for Executor {
|
||||
println!("failed to persist tempdir: {e}");
|
||||
}
|
||||
|
||||
if let Err(e) = self.child.kill() {
|
||||
println!("failed to kill the child process: {e}");
|
||||
}
|
||||
kill_child(&mut self.child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ use crate::{
|
||||
common::{
|
||||
binary::{BinaryConfig, BinaryResolver},
|
||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
||||
lifecycle::kill::kill_child,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -66,19 +67,14 @@ impl Drop for Validator {
|
||||
println!("failed to persist tempdir: {e}");
|
||||
}
|
||||
|
||||
if let Err(e) = self.child.kill() {
|
||||
println!("failed to kill the child process: {e}");
|
||||
}
|
||||
kill_child(&mut self.child);
|
||||
}
|
||||
}
|
||||
|
||||
impl Validator {
|
||||
/// Check if the validator process is still running
|
||||
pub fn is_running(&mut self) -> bool {
|
||||
match self.child.try_wait() {
|
||||
Ok(None) => true,
|
||||
Ok(Some(_)) | Err(_) => false,
|
||||
}
|
||||
crate::nodes::common::lifecycle::monitor::is_running(&mut self.child)
|
||||
}
|
||||
|
||||
/// Wait for the validator process to exit, with a timeout
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user