1 unstable release
0.1.0 | Dec 6, 2020 |
---|
#30 in #kill
7KB
65 lines
Vorarbeiter, a small process supervisor
vorarbeiter::Supervisor
shuts down processes it owns on Drop
by sending a SIGTERM
first, followed by a SIGKILL
:
use std::process;
// The default kill timeout is 10 seconds, which is fine here.
let mut supervisor = vorarbeiter::Supervisor::default();
// Spawns three new child processes and adds them to the supervisor.
for _ in 0..3 {
let child = process::Command::new("my-subcommand").spawn().unwrap();
supervisor.add_child(child);
}
// Terminate all child processes.
drop(supervisor);
See the documentation for details.
lib.rs
:
A supervisor for processes that allow clean shutdowns.
See Supervisor
for the core functionality. Real applications will likely want to use
setup_term_flag
as well.
Example
use std::process;
// The default kill timeout is 10 seconds, which is fine here.
let mut supervisor = vorarbeiter::Supervisor::default();
// Spawns three new child processes and adds them to the supervisor.
for _ in 0..3 {
let child = process::Command::new("my-subcommand").spawn().unwrap();
supervisor.add_child(child);
}
// Terminate all child processes, waiting for each to be completed or killed.
drop(supervisor);
Dependencies
~2MB
~37K SLoC