File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -287,9 +287,30 @@ impl NodeArgs {
287287 let mut state_dumper = PeriodicStateDumper :: new ( api, dump_state, dump_interval) ;
288288
289289 task_manager. spawn ( async move {
290+ // wait for the SIGTERM signal on unix systems
291+ #[ cfg( unix) ]
292+ let mut sigterm = Box :: pin ( async {
293+ if let Ok ( mut stream) =
294+ tokio:: signal:: unix:: signal ( tokio:: signal:: unix:: SignalKind :: terminate ( ) )
295+ {
296+ stream. recv ( ) . await ;
297+ } else {
298+ futures:: future:: pending :: < ( ) > ( ) . await ;
299+ }
300+ } ) ;
301+
302+ // on windows, this will never fires
303+ #[ cfg( not( unix) ) ]
304+ let mut sigterm = Box :: pin ( futures:: future:: pending :: < ( ) > ( ) ) ;
305+
290306 // await shutdown signal but also periodically flush state
291307 tokio:: select! {
292- _ = & mut on_shutdown =>{ }
308+ _ = & mut sigterm => {
309+ trace!( "received sigterm signal, shutting down" ) ;
310+ } ,
311+ _ = & mut on_shutdown =>{
312+
313+ }
293314 _ = & mut state_dumper =>{ }
294315 }
295316
You can’t perform that action at this time.
0 commit comments