Skip to content

Commit

Permalink
Add -V/--verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel committed Jul 31, 2021
1 parent aba2aa0 commit 61beb09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use argh::FromArgs;
#[derive(FromArgs)]
/// Lightweight process killer daemon for out-of-memory scenarios
pub struct CommandLineArgs {
/// toggles on verbose output
#[argh(switch, short = 'V')]
pub verbose: bool,

/// when set, bustd will kill the victim's entire process group
#[argh(switch, short = 'g')]
pub group: bool,
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn main() -> error::Result<()> {

if !args.no_daemon {
// Daemonize current process
println!("\nStarting daemonization process!");
daemon::daemonize()?;
}

Expand Down
4 changes: 3 additions & 1 deletion src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ impl Monitor {

// Calculating the adaptive sleep time
let sleep_time = self.sleep_time_ms();
eprintln!("Sleeping {}ms", sleep_time.as_millis());
if self.args.verbose {
eprintln!("[adaptive-sleep] {}ms", sleep_time.as_millis());
}

std::thread::sleep(sleep_time);
}
Expand Down

0 comments on commit 61beb09

Please sign in to comment.