Set 10 minute timeout on background job that processes incoming activities

https://codeberg.org/silverpill/mitra/issues/24
This commit is contained in:
silverpill 2023-02-02 20:46:03 +00:00
parent e784476344
commit 8bb786c763
2 changed files with 7 additions and 1 deletions

View file

@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added `https://w3id.org/security/data-integrity/v1` to JSON-LD context. - Added `https://w3id.org/security/data-integrity/v1` to JSON-LD context.
- Return `202 Accepted` when activity is accepted by inbox endpoint. - Return `202 Accepted` when activity is accepted by inbox endpoint.
- Ignore forwarded `Like` activities. - Ignore forwarded `Like` activities.
- Set 10 minute timeout on background job that processes incoming activities.
## [1.12.0] - 2023-01-26 ## [1.12.0] - 2023-01-26

View file

@ -122,7 +122,12 @@ async fn incoming_activity_queue_task(
db_pool: &DbPool, db_pool: &DbPool,
) -> Result<(), Error> { ) -> Result<(), Error> {
let db_client = &mut **get_database_client(db_pool).await?; let db_client = &mut **get_database_client(db_pool).await?;
process_queued_incoming_activities(config, db_client).await?; let duration_max = Duration::from_secs(600);
let task_completed = process_queued_incoming_activities(config, db_client);
match tokio::time::timeout(duration_max, task_completed).await {
Ok(result) => result?,
Err(_) => log::error!("task timeout: IncomingActivityQueue"),
};
Ok(()) Ok(())
} }