How to handle Ctrl+C/SIGINT with own code #2395
-
Hey there, I tried using the ctrlc crate to handle SIGINT so I can add my own code to it (to save some values), but it seems that rocket's handler is overriding it. What's the recommended way to add my own code to Rocket's shutdown sequence so I can save these values? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You simply need to disable Rocket's default handler. See the config guide and API docs for how: https://rocket.rs/v0.5-rc/guide/configuration/ and https://api.rocket.rs/v0.5-rc/rocket/config/struct.Shutdown.html#example. If you want to shutdown as well, then you'll need to call shutdown() from your signal handler. |
Beta Was this translation helpful? Give feedback.
You simply need to disable Rocket's default handler. See the config guide and API docs for how: https://rocket.rs/v0.5-rc/guide/configuration/ and https://api.rocket.rs/v0.5-rc/rocket/config/struct.Shutdown.html#example. If you want to shutdown as well, then you'll need to call shutdown() from your signal handler.