pub struct ProcessManager { /* private fields */ }Expand description
Manages external child processes with graceful shutdown and dependency ordering
ProcessManager tracks and manages child processes spawned as external binaries. It provides:
- Process tracking with PIDs
- Dependency-based shutdown ordering
- Graceful shutdown with configurable timeout
- Force kill fallback
- Integration with runtime’s ShutdownHandle
Implementations§
Source§impl ProcessManager
impl ProcessManager
Sourcepub fn with_shutdown_handle(shutdown_handle: ShutdownHandle) -> Self
pub fn with_shutdown_handle(shutdown_handle: ShutdownHandle) -> Self
Create a new process manager with shutdown handle
Sourcepub fn set_shutdown_timeout(&mut self, timeout: Duration)
pub fn set_shutdown_timeout(&mut self, timeout: Duration)
Set the default shutdown timeout
Sourcepub fn add_dependency(&mut self, node: String, dependency: String)
pub fn add_dependency(&mut self, node: String, dependency: String)
Add a dependency relationship
Specifies that node depends on dependency and should be stopped before it.
§Arguments
node- The node that depends on anotherdependency- The node that is depended upon
Sourcepub fn status_all(&mut self) -> HashMap<String, ProcessStatus>
pub fn status_all(&mut self) -> HashMap<String, ProcessStatus>
Get status of all processes
Sourcepub fn processes(&mut self) -> Vec<ProcessInfo>
pub fn processes(&mut self) -> Vec<ProcessInfo>
Get information about all tracked processes
Sourcepub fn shutdown_order(&self) -> Vec<String>
pub fn shutdown_order(&self) -> Vec<String>
Calculate shutdown order based on dependency graph
Returns nodes in the order they should be stopped (dependents before dependencies).
Sourcepub fn force_kill(&mut self, name: &str) -> Result<()>
pub fn force_kill(&mut self, name: &str) -> Result<()>
Force kill a process immediately
Sourcepub fn shutdown_all(&mut self)
pub fn shutdown_all(&mut self)
Stop all processes in dependency order with graceful shutdown
Sourcepub fn is_running(&mut self, name: &str) -> bool
pub fn is_running(&mut self, name: &str) -> bool
Check if a specific process is running
Trait Implementations§
Source§impl Default for ProcessManager
impl Default for ProcessManager
Auto Trait Implementations§
impl Freeze for ProcessManager
impl !RefUnwindSafe for ProcessManager
impl Send for ProcessManager
impl Sync for ProcessManager
impl Unpin for ProcessManager
impl !UnwindSafe for ProcessManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more