loco
loco copied to clipboard
"Before Shutdown" hooks for more control over a graceful termination
In the "after_routes" hook, I am allocating multiple unix file descriptors and spawning multiple external processes that my application needs to interact with over the course of its lifetime.
Since these are external to my application (and external to Rust), I need to terminate them gracefully when my application terminates, or else I can leak file descriptors or cause zombie processes.
Right now to solve this I have to override the serve hook and hook into Axum's graceful shutdown.
It would be nice not to have to do that and instead have access to a "before_server_shutdown" / "after_server_shutdown" / "main_process_stop" hook where I can gracefully end all the external processes I started.