mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-05-23 01:59:46 +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 cleanup;
|
||||||
|
pub mod kill;
|
||||||
pub mod monitor;
|
pub mod monitor;
|
||||||
pub mod spawn;
|
pub mod spawn;
|
||||||
|
|||||||
@ -1,4 +1,11 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
/// Shared monitoring helpers (placeholder).
|
use std::process::Child;
|
||||||
pub struct Monitor;
|
|
||||||
|
/// 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::{
|
common::{
|
||||||
binary::{BinaryConfig, BinaryResolver},
|
binary::{BinaryConfig, BinaryResolver},
|
||||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
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}");
|
println!("failed to persist tempdir: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = self.child.kill() {
|
kill_child(&mut self.child);
|
||||||
println!("failed to kill the child process: {e}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ use crate::{
|
|||||||
common::{
|
common::{
|
||||||
binary::{BinaryConfig, BinaryResolver},
|
binary::{BinaryConfig, BinaryResolver},
|
||||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
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}");
|
println!("failed to persist tempdir: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = self.child.kill() {
|
kill_child(&mut self.child);
|
||||||
println!("failed to kill the child process: {e}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Validator {
|
impl Validator {
|
||||||
/// Check if the validator process is still running
|
/// Check if the validator process is still running
|
||||||
pub fn is_running(&mut self) -> bool {
|
pub fn is_running(&mut self) -> bool {
|
||||||
match self.child.try_wait() {
|
crate::nodes::common::lifecycle::monitor::is_running(&mut self.child)
|
||||||
Ok(None) => true,
|
|
||||||
Ok(Some(_)) | Err(_) => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for the validator process to exit, with a timeout
|
/// Wait for the validator process to exit, with a timeout
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user