Skip to content

Commit 7c3e8b6

Browse files
taco-pacoDodecahedr0x
authored andcommitted
feat: add shutdown logs (#770)
1 parent 3a8334f commit 7c3e8b6

File tree

7 files changed

+21
-33
lines changed

7 files changed

+21
-33
lines changed

magicblock-api/src/magic_validator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ impl MagicValidator {
279279
.build()
280280
.expect("failed to bulid async runtime for rpc service");
281281
runtime.block_on(rpc.run());
282+
283+
drop(runtime);
284+
info!("rpc runtime shutdown!");
282285
});
283286

284287
let task_scheduler_db_path =
@@ -546,6 +549,7 @@ impl MagicValidator {
546549
.map_err(|err| {
547550
ApiError::FailedToUnregisterValidatorOnChain(format!("{err:#}"))
548551
})
552+
.inspect(|_| info!("Unregistered validator on chain!"))
549553
}
550554

551555
async fn ensure_validator_funded_on_chain(&self) -> ApiResult<()> {
@@ -687,6 +691,8 @@ impl MagicValidator {
687691
if let Err(err) = self.ledger_truncator.join() {
688692
error!("Ledger truncator did not gracefully exit: {:?}", err);
689693
}
694+
695+
info!("MagicValidator shutdown!");
690696
}
691697

692698
pub fn ledger(&self) -> &Ledger {

magicblock-api/src/tickers.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,6 @@ pub fn init_system_metrics_ticker(
108108
accountsdb: &Arc<AccountsDb>,
109109
token: CancellationToken,
110110
) -> tokio::task::JoinHandle<()> {
111-
fn try_set_ledger_counts(ledger: &Ledger) {
112-
macro_rules! try_set_ledger_count {
113-
($name:ident) => {
114-
paste::paste! {
115-
match ledger.[< count_ $name >]() {
116-
Ok(count) => {
117-
metrics::[< set_ledger_ $name _count >](count);
118-
}
119-
Err(err) => warn!(
120-
"Failed to get ledger {} count: {:?}",
121-
stringify!($name),
122-
err
123-
),
124-
}
125-
}
126-
};
127-
}
128-
try_set_ledger_count!(block_times);
129-
try_set_ledger_count!(blockhashes);
130-
try_set_ledger_count!(slot_signatures);
131-
try_set_ledger_count!(address_signatures);
132-
try_set_ledger_count!(transaction_status);
133-
try_set_ledger_count!(transaction_successful_status);
134-
try_set_ledger_count!(transaction_failed_status);
135-
try_set_ledger_count!(transactions);
136-
try_set_ledger_count!(transaction_memos);
137-
try_set_ledger_count!(perf_samples);
138-
try_set_ledger_count!(account_mod_data);
139-
}
140-
141111
fn try_set_ledger_storage_size(ledger: &Ledger) {
142112
match ledger.storage_size() {
143113
Ok(byte_size) => metrics::set_ledger_size(byte_size),
@@ -165,13 +135,14 @@ pub fn init_system_metrics_ticker(
165135
_ = tokio::time::sleep(tick_duration) => {
166136
try_set_ledger_storage_size(&ledger);
167137
set_accounts_storage_size(&bank);
168-
metrics::observe_columns_count_duration(|| try_set_ledger_counts(&ledger));
169138
set_accounts_count(&bank);
170139
},
171140
_ = token.cancelled() => {
172141
break;
173142
}
174143
}
175144
}
145+
146+
info!("System metrics ticker shutdown!");
176147
})
177148
}

magicblock-committor-service/src/service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ impl CommittorActor {
245245
}
246246
}
247247
}
248+
249+
info!("CommittorActor shutdown!");
248250
}
249251
}
250252

magicblock-ledger/src/ledger_truncator.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,15 @@ impl LedgerTruncator {
475475
self.stop();
476476
}
477477

478-
if let ServiceState::Stopped(worker_handle) = self.state {
478+
let res = if let ServiceState::Stopped(worker_handle) = self.state {
479479
worker_handle.join()
480480
} else {
481481
warn!("LedgerTruncator was not running, nothing to stop");
482482
Ok(())
483-
}
483+
};
484+
info!("LedgerTruncator shutdown!");
485+
486+
res
484487
}
485488
}
486489

magicblock-metrics/src/service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ impl MetricsService {
8787
}
8888
);
8989
}
90+
91+
info!("MetricsService shutdown!");
9092
})
9193
}
9294
}

magicblock-task-scheduler/src/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ impl TaskSchedulerService {
289289
}
290290
}
291291

292+
info!("TaskSchedulerService shutdown!");
292293
Ok(())
293294
}
294295

magicblock-validator/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ fn main() {
5959
.build()
6060
.expect("failed to build async runtime");
6161
runtime.block_on(run());
62+
drop(runtime);
63+
64+
info!("main runtime shutdown!");
6265
}
6366

6467
async fn run() {

0 commit comments

Comments
 (0)