File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ mod args;
33#[ tokio:: main]
44async fn main ( ) {
55 use clap:: { CommandFactory , Parser } ;
6+ use tokio:: signal:: unix:: SignalKind ;
67 use tracing:: { error, info} ;
78
89 // Parse command-line arguments.
@@ -45,7 +46,9 @@ async fn main() {
4546 let cxl_child = cxl. clone ( ) ;
4647 let mut handle = tokio:: spawn ( async move { cxl_child. cancelled ( ) . await } ) ;
4748
48- // Wait for server exit or SIGINT.
49+ // Wait for server exit or SIGTERM/SIGINT.
50+ let mut sigterm = tokio:: signal:: unix:: signal ( SignalKind :: terminate ( ) ) . unwrap ( ) ;
51+ let mut sigint = tokio:: signal:: unix:: signal ( SignalKind :: interrupt ( ) ) . unwrap ( ) ;
4952 tokio:: select! {
5053 res = tokio:: signal:: ctrl_c( ) => {
5154 res. expect( "Failed to register SIGINT hook" ) ;
@@ -55,6 +58,8 @@ async fn main() {
5558
5659 handle. await . unwrap( ) ;
5760 }
61+ _ = sigterm. recv( ) => info!( "SIGTERM caught, stopping server" ) ,
62+ _ = sigint. recv( ) => info!( "SIGINT caught, stopping server" ) ,
5863 res = & mut handle => {
5964 res. unwrap( ) ;
6065 }
You can’t perform that action at this time.
0 commit comments