Skip to content

Commit

Permalink
feat: shutdown with exit code (#865)
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
  • Loading branch information
simonsan committed Mar 5, 2024
1 parent 146e3b7 commit d2d86ea
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 d2d86ea

Please sign in to comment.