run workers on startup instead of sleeping first

This commit is contained in:
Armaël Guéneau 2024-12-20 10:19:54 +01:00
parent a3c9105caa
commit 4f896d8ada

View file

@ -70,10 +70,10 @@ pub async fn refresh_user_data(
classifier: Arc<Mutex<Classifier>>,
) {
loop {
tokio::time::sleep(FORGEJO_POLL_DELAY.mul_f32(0.1)).await;
if let Err(e) = try_refresh_user_data(&forge, db.clone(), classifier.clone()).await {
eprintln!("Error refreshing user data: {:?}", e);
}
tokio::time::sleep(FORGEJO_POLL_DELAY.mul_f32(0.1)).await;
}
}
@ -91,8 +91,6 @@ async fn try_purge_account(forge: &Forgejo, login: &str) -> anyhow::Result<()> {
pub async fn purge_spammer_accounts(forge: Arc<Forgejo>, db: Arc<Mutex<Db>>) {
loop {
tokio::time::sleep(std::time::Duration::from_secs(3600)).await;
let mut classified_users = Vec::new();
{
let db = &db.lock().unwrap();
@ -121,5 +119,7 @@ pub async fn purge_spammer_accounts(forge: Arc<Forgejo>, db: Arc<Mutex<Db>>) {
}
}
}
tokio::time::sleep(std::time::Duration::from_secs(3600)).await;
}
}