mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-12 04:55:55 +00:00
better logging
This commit is contained in:
parent
3f511687d1
commit
080c380135
2 changed files with 14 additions and 3 deletions
|
@ -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: less noisy output (only output failing instances and summary for successful)
|
||||||
// todo: more stats (act/sec, avg http req duration)
|
// todo: more stats (act/sec, avg http req duration)
|
||||||
|
let mut ok_count = 0;
|
||||||
for stat in stats.values() {
|
for stat in stats.values() {
|
||||||
let behind = last_id - stat.last_successful_id;
|
let behind = last_id - stat.last_successful_id;
|
||||||
if stat.fail_count > 0 {
|
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)
|
retry_sleep_duration(stat.fail_count)
|
||||||
);
|
);
|
||||||
} else {
|
} 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");
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,14 +107,19 @@ pub async fn instance_worker(
|
||||||
let mut req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?;
|
let mut req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?;
|
||||||
tracing::info!("sending out {}", task);
|
tracing::info!("sending out {}", task);
|
||||||
while let Err(e) = send_raw(&task, &data, req).await {
|
while let Err(e) = send_raw(&task, &data, req).await {
|
||||||
tracing::info!("{task} failed: {e}");
|
|
||||||
state.fail_count += 1;
|
state.fail_count += 1;
|
||||||
state.last_retry = Utc::now();
|
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())?;
|
stats_sender.send(state.clone())?;
|
||||||
FederationQueueState::upsert(&mut pool, &state).await?;
|
FederationQueueState::upsert(&mut pool, &state).await?;
|
||||||
req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?; // resign request
|
req = sign_raw(&task, &data, REQWEST_TIMEOUT).await?; // resign request
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
() = sleep(retry_sleep_duration(state.fail_count)) => {},
|
() = sleep(retry_delay) => {},
|
||||||
() = stop.cancelled() => {
|
() = stop.cancelled() => {
|
||||||
// save state to db and exit
|
// save state to db and exit
|
||||||
break 'batch;
|
break 'batch;
|
||||||
|
|
Loading…
Reference in a new issue