File tree 1 file changed +29
-10
lines changed 1 file changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -254,18 +254,37 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {
254
254
. await
255
255
. unwrap ( ) ;
256
256
257
- let res = tokio:: select! {
258
- _ = tokio:: signal:: ctrl_c( ) => {
259
- tracing:: info!( "receive ctrl+c" ) ;
260
- shutdown_send. send( ( ) ) . unwrap( ) ;
261
- join_handle. await
257
+ match leader_lost_handle {
258
+ None => {
259
+ tokio:: select! {
260
+ _ = tokio:: signal:: ctrl_c( ) => {
261
+ tracing:: info!( "receive ctrl+c" ) ;
262
+ shutdown_send. send( ( ) ) . unwrap( ) ;
263
+ join_handle. await . unwrap( )
264
+ }
265
+ res = & mut join_handle => res. unwrap( ) ,
266
+ } ;
267
+ }
268
+ Some ( mut handle) => {
269
+ tokio:: select! {
270
+ _ = & mut handle => {
271
+ tracing:: info!( "receive leader lost signal" ) ;
272
+ shutdown_send. send( ( ) ) . unwrap( ) ;
273
+ join_handle. await . unwrap( )
274
+ }
275
+ _ = tokio:: signal:: ctrl_c( ) => {
276
+ tracing:: info!( "receive ctrl+c" ) ;
277
+ shutdown_send. send( ( ) ) . unwrap( ) ;
278
+ join_handle. await . unwrap( ) ;
279
+ handle. abort( ) ;
280
+ }
281
+ res = & mut join_handle => {
282
+ res. unwrap( ) ;
283
+ handle. abort( ) ;
284
+ } ,
285
+ } ;
262
286
}
263
- res = & mut join_handle => res,
264
287
} ;
265
- res. unwrap ( ) ;
266
- if let Some ( leader_lost_handle) = leader_lost_handle {
267
- leader_lost_handle. abort ( ) ;
268
- }
269
288
} )
270
289
}
271
290
You can’t perform that action at this time.
0 commit comments