lemmy
lemmy copied to clipboard
Handling shutdown for background tasks
Lemmy has various tasks which run in the background:
- collect notified users for post/comment
- send out emails
- send webmention for post
- import user settings
- generate metadata for incoming federated posts
- purge images for user (https://github.com/LemmyNet/lemmy/pull/5883)
All of these should be properly handled on shutdown, meaning Lemmy should wait until they are completed before exiting, or otherwise store the task in the database so it can be resumed on the next start. crates/federate already has logic like this for outgoing federation.
Ideally this would be done in a generic way, to avoid writing the same logic for each background task like in https://github.com/LemmyNet/lemmy/pull/5877. Maybe we can use an existing library for this eg rusty-sidekiq