better logging

This commit is contained in:
phiresky 2023-07-24 14:32:27 +00:00
parent 3f511687d1
commit 080c380135
2 changed files with 14 additions and 3 deletions

View File

@ -158,6 +158,7 @@ async fn print_stats(pool: &mut DbPool<'_>, stats: &HashMap<String, FederationQu
);
// todo: less noisy output (only output failing instances and summary for successful)
// todo: more stats (act/sec, avg http req duration)
let mut ok_count = 0;
for stat in stats.values() {
let behind = last_id - stat.last_successful_id;
if stat.fail_count > 0 {
@ -169,7 +170,12 @@ async fn print_stats(pool: &mut DbPool<'_>, stats: &HashMap<String, FederationQu
retry_sleep_duration(stat.fail_count)
);
} else {
tracing::info!("{}: Ok. {} behind", stat.domain, behind);
if behind > 0 {
tracing::info!("{}: Ok. {} behind", stat.domain, behind);
} else {
ok_count += 1;
}
}
}
tracing::info!("{ok_count} others up to date");
}

View File

@ -107,14 +107,19 @@ pub async fn instance_worker(
let mut req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?;
tracing::info!("sending out {}", task);
while let Err(e) = send_raw(&task, &data, req).await {
tracing::info!("{task} failed: {e}");
state.fail_count += 1;
state.last_retry = Utc::now();
let retry_delay: Duration = retry_sleep_duration(state.fail_count);
tracing::info!(
"{}: retrying {id} attempt {} with delay {retry_delay:.2?}. ({e})",
instance.domain,
state.fail_count
);
stats_sender.send(state.clone())?;
FederationQueueState::upsert(&mut pool, &state).await?;
req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?; // resign request
tokio::select! {
() = sleep(retry_sleep_duration(state.fail_count)) => {},
() = sleep(retry_delay) => {},
() = stop.cancelled() => {
// save state to db and exit
break 'batch;