Cactus/handlers.rs
1use log::info;
2
3use crate::shutdown::{self, ExitCode};
4
5/// Sets up a behavior when the user executes CTRL + C.
6pub fn init_ctrlc_handler() -> Result<(), Box<dyn std::error::Error>> {
7 ctrlc::set_handler(move || {
8 info!("Received Ctrl+C, shutting down...");
9 shutdown::gracefully_exit(ExitCode::CtrlC);
10 })?;
11
12 Ok(())
13}