Skip to content

Commit

Permalink
feat: shutdown with exit code
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 5, 2024
1 parent 31bdced commit 2b99956
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ pub trait Application: Default + Sized + 'static {

process::exit(0);
}

/// Shut down this application gracefully, exiting with user-defined exit code.
fn shutdown_with_exitcode(&self, shutdown: Shutdown, exit_code: i32) -> ! {
let components = self.state().components();

if let Err(e) = components.shutdown(self, shutdown) {
fatal_error(self, &e)
}

process::exit(exit_code);
}
}

/// Boot the given application, parsing subcommand and options from
Expand Down

0 comments on commit 2b99956

Please sign in to comment.