mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	feat(Core): gracefully shutdown router/scheduler if Redis is unavailable (#891)
Co-authored-by: prajjwal kumar <prajjwal.kumar@prajjwalkumar-DWKH9NPY4R.local> Co-authored-by: Nishant Joshi <nishant.joshi@juspay.in> Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
		| @ -2,20 +2,21 @@ | ||||
|  | ||||
| use futures::StreamExt; | ||||
| use router_env::logger; | ||||
| pub use tokio::sync::oneshot; | ||||
| use tokio::sync::mpsc; | ||||
|  | ||||
| /// | ||||
| /// This functions is meant to run in parallel to the application. | ||||
| /// It will send a signal to the receiver when a SIGTERM or SIGINT is received | ||||
| /// | ||||
| pub async fn signal_handler(mut sig: signal_hook_tokio::Signals, sender: oneshot::Sender<()>) { | ||||
| pub async fn signal_handler(mut sig: signal_hook_tokio::Signals, sender: mpsc::Sender<()>) { | ||||
|     if let Some(signal) = sig.next().await { | ||||
|         logger::info!( | ||||
|             "Received signal: {:?}", | ||||
|             signal_hook::low_level::signal_name(signal) | ||||
|         ); | ||||
|         match signal { | ||||
|             signal_hook::consts::SIGTERM | signal_hook::consts::SIGINT => match sender.send(()) { | ||||
|             signal_hook::consts::SIGTERM | signal_hook::consts::SIGINT => match sender.try_send(()) | ||||
|             { | ||||
|                 Ok(_) => { | ||||
|                     logger::info!("Request for force shutdown received") | ||||
|                 } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Prajjwal Kumar
					Prajjwal Kumar