Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-zero exit codes with Application::shutdown() #857

Closed
simonsan opened this issue Dec 4, 2023 · 5 comments · Fixed by #865
Closed

Allow non-zero exit codes with Application::shutdown() #857

simonsan opened this issue Dec 4, 2023 · 5 comments · Fixed by #865

Comments

@simonsan
Copy link
Contributor

simonsan commented Dec 4, 2023

Currently, shutdown always returns 0 as exit code:

/// Shut down this application gracefully, exiting with success.
fn shutdown(&self, shutdown: Shutdown) -> ! {
let components = self.state().components();
if let Err(e) = components.shutdown(self, shutdown) {
fatal_error(self, &e)
}
process::exit(0);
}

As a user of abscissa I would expect the following to return a non-zero exit code, when I pass Shutdown::Crash, though.

 if let Err(err) = self.inner_run() {
            status_err!("{}", err);
            APP.shutdown(Shutdown::Crash);
        };

What's the opinion on changing that, to allow non-zero exit codes? We could directly return and call process::exit() ourselves, for sure. I'm unsure, though, whether it wouldn't be nice to stay within abscissa to let all the other components shutting down gracefully, while still exiting with a non-zero exit code.

EDIT:

Maybe utilizing https://docs.rs/exitcode/1.1.2/exitcode/ these numbers?

 /// Shut down this application gracefully, exiting with your given `exit_code`. 
 fn shutdown_with_exit_code(&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); 
 }
@aawsome
Copy link

aawsome commented Feb 26, 2024

Any news on this?

@simonsan
Copy link
Contributor Author

simonsan commented Mar 7, 2024

@tony-iqlusion No stress, but it would be really awesome if there would be a new patch release (if applicable) for this, so we can use this in rustic and backups don't fail silently in scripts any more. The workaround would need to manually exit in a lot of places. :/

@tony-iqlusion
Copy link
Member

There are some additional changes I'd like to make first, but I will try to get another release out soon

@simonsan
Copy link
Contributor Author

simonsan commented Mar 7, 2024

There are some additional changes I'd like to make first, but I will try to get another release out soon

Great, thank you! <3 Anything oneself can/you need help with?

@aawsome
Copy link

aawsome commented Apr 15, 2024

Don't want to put any pressure. Just wanted to mention that a release would help us to close an high-priority issue in https://github.com/rustic-rs/rustic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants