From 8ed9a6aeb969d7f47a513f33c0bf6b28c28693b2 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Fri, 9 Feb 2024 10:23:38 +0800 Subject: [PATCH 1/2] IndexerService should use `is_cancelled()` to check if ckb received ctrl-c signal --- util/indexer/src/service.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/util/indexer/src/service.rs b/util/indexer/src/service.rs index 6a8d059162..0bbb0c2056 100644 --- a/util/indexer/src/service.rs +++ b/util/indexer/src/service.rs @@ -238,13 +238,9 @@ impl IndexerService { self.async_handle.spawn(async move { let _initial_finished = initial_syncing.await; info!("initial_syncing finished"); - - tokio::select! { - _ = stop.cancelled() => { - info!("Indexer received exit signal, cancel new_block_watcher task, exit now"); - return; - }, - else => {}, + if stop.is_cancelled() { + info!("Indexer received exit signal, cancel new_block_watcher task, exit now"); + return; } let mut new_block_watcher = notify_controller From 652ce501bfc3da89f1c3082e148eed95800cc8e4 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Fri, 9 Feb 2024 10:46:47 +0800 Subject: [PATCH 2/2] IndexerService: fix exit exit signal bats test --- util/app-config/src/tests/graceful_shutdown.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/app-config/src/tests/graceful_shutdown.bats b/util/app-config/src/tests/graceful_shutdown.bats index 6d6aa5e82e..17ac2661b3 100644 --- a/util/app-config/src/tests/graceful_shutdown.bats +++ b/util/app-config/src/tests/graceful_shutdown.bats @@ -26,7 +26,7 @@ function ckb_graceful_shutdown { #@test assert_output --regexp "INFO ckb_tx_pool::chunk_process TxPool chunk_command service received exit signal, exit now" assert_output --regexp "INFO ckb_tx_pool::service TxPool is saving, please wait..." assert_output --regexp "INFO ckb_tx_pool::service TxPool reorg process service received exit signal, exit now" - assert_output --regexp "INFO ckb_indexer::service Indexer received exit signal, cancel new_block_watcher task, exit now" + assert_output --regexp "INFO ckb_indexer::service Indexer received exit signal, exit now" assert_output --regexp "INFO ckb_notify NotifyService received exit signal, exit now" assert_output --regexp "INFO ckb_block_filter::filter BlockFilter received exit signal, exit now" assert_output --regexp "INFO ckb_sync::types::header_map HeaderMap limit_memory received exit signal, exit now"