@@ -26,6 +26,7 @@ use redact::Secret;
26
26
use risingwave_common:: config:: OverrideConfig ;
27
27
use risingwave_common:: util:: meta_addr:: MetaAddressStrategy ;
28
28
use risingwave_common:: util:: resource_util;
29
+ use risingwave_common:: util:: tokio_util:: sync:: CancellationToken ;
29
30
use risingwave_common:: { GIT_SHA , RW_VERSION } ;
30
31
use risingwave_common_heap_profiling:: HeapProfiler ;
31
32
use risingwave_meta:: * ;
@@ -204,7 +205,10 @@ use risingwave_common::config::{load_config, MetaBackend, RwConfig};
204
205
use tracing:: info;
205
206
206
207
/// Start meta node
207
- pub fn start ( opts : MetaNodeOpts ) -> Pin < Box < dyn Future < Output = ( ) > + Send > > {
208
+ pub fn start (
209
+ opts : MetaNodeOpts ,
210
+ shutdown : CancellationToken ,
211
+ ) -> Pin < Box < dyn Future < Output = ( ) > + Send > > {
208
212
// WARNING: don't change the function signature. Making it `async fn` will cause
209
213
// slow compile in release mode.
210
214
Box :: pin ( async move {
@@ -324,7 +328,7 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {
324
328
max_timeout_ms / 1000
325
329
} + MIN_TIMEOUT_INTERVAL_SEC ;
326
330
327
- let ( mut join_handle , leader_lost_handle , shutdown_send ) = rpc_serve (
331
+ rpc_serve (
328
332
add_info,
329
333
backend,
330
334
max_heartbeat_interval,
@@ -428,42 +432,10 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {
428
432
} ,
429
433
config. system . into_init_system_params ( ) ,
430
434
Default :: default ( ) ,
435
+ shutdown,
431
436
)
432
437
. await
433
438
. unwrap ( ) ;
434
-
435
- tracing:: info!( "Meta server listening at {}" , listen_addr) ;
436
-
437
- match leader_lost_handle {
438
- None => {
439
- tokio:: select! {
440
- _ = tokio:: signal:: ctrl_c( ) => {
441
- tracing:: info!( "receive ctrl+c" ) ;
442
- shutdown_send. send( ( ) ) . unwrap( ) ;
443
- join_handle. await . unwrap( )
444
- }
445
- res = & mut join_handle => res. unwrap( ) ,
446
- } ;
447
- }
448
- Some ( mut handle) => {
449
- tokio:: select! {
450
- _ = & mut handle => {
451
- tracing:: info!( "receive leader lost signal" ) ;
452
- // When we lose leadership, we will exit as soon as possible.
453
- }
454
- _ = tokio:: signal:: ctrl_c( ) => {
455
- tracing:: info!( "receive ctrl+c" ) ;
456
- shutdown_send. send( ( ) ) . unwrap( ) ;
457
- join_handle. await . unwrap( ) ;
458
- handle. abort( ) ;
459
- }
460
- res = & mut join_handle => {
461
- res. unwrap( ) ;
462
- handle. abort( ) ;
463
- } ,
464
- } ;
465
- }
466
- } ;
467
439
} )
468
440
}
469
441
0 commit comments