lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Handling shutdown for background tasks

Open Nutomic opened this issue 5 months ago • 0 comments

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

Nutomic avatar Jul 28 '25 12:07 Nutomic