This crate consists of a convenient macro to specify on shutdown callbacks called on_shutdown!
. It takes code that
should be executed when your program exits (gracefully). See https://docs.rs/simpleonshutdown for more info.
Useful with "runtimes you do not have control over", like for example actix-web framework doesn't let you specify shutdown callbacks by yourself. In such cases my macro may be a better option.
```rust use simpleonshutdown::on_shutdown;
fn main() { // macro can take: direct expression onshutdown!(println!("shut down with success")); // closure expression onshutdown!(|| println!("shut down with success")); // move closure expression onshutdown!(move || println!("shut down with success")); // block onshutdown!({ println!("shut down with success") }); // identifier let identifier = || println!("shut down with success"); on_shutdown!(identifier); }
```
See "examples/"-dir in repository!.
CTRL+C / SIGINT / SIGTERM
SIGINT/SIGTERM
(and other signals) properly to allow a gracefully "non-regular"
shutdown (Actix web framework does this for example)
CTRL+C
will immediately shut down your appexample/src/bin/simple_example_ctrl_c_signal
for
more details.