[−][src]Crate simple_on_shutdown
This crate consists of a convenient macro to specify on shutdown callbacks.
This is useful for all runtimes you do not have control over. There is no guarantee
that this gets executed during "non-regular" shutdown scenarios, like CTRL+C / SIGINT / SIGTERM
.
This depends whether your application properly handles signals and if the operating system
gives your application time before it gets totally killed/stopped.
The generated main() function of an "actix" web server is a good example where this crate
can be used. With the exported macro on_shutdown
you can easily specify code, that should run
during program termination. In Actix it works in CTRL+C / SIGINT / SIGTERM
-scenarios.
IMPORTANT: Use this on the top level of your main() or whatever your current runtimes main function is! The code gets executed when the context it lives in gets dropped. This can be called multiple times (at least with stable Rust 1.48.0) without problem.
This crate uses the log
crate on the debug
level.
Macros
on_shutdown | Convenient constructor macro for [ |
Structs
OnShutdownCallback | Simple type that holds a closure (callback). The closure gets invoked during |