Files
danbooru/app/jobs
evazion 02edb52569 uploads: enable multi-file uploads when uploading from source.
Make the upload page automatically detect when a source URL has multiple images
and let the user choose which images to post.

For example, when uploading a Twitter or Pixiv post with more than one image, we
direct the user to a page showing a thumbnail for each image and letting
them choose which ones to post.

This is similar to the batch upload page, except we actually download each image
in the background, instead of just hotlinking or proxying the thumbnails through
our servers. This avoids various problems with proxying and makes new features
possible, like showing which images in the batch have already been posted.
2022-02-14 16:13:55 -06:00
..

Jobs

This directory contains background jobs used by Danbooru. Jobs are used to handle slow-running tasks that need to run in the background, such as processing uploads or bulk update requests. They're also used for asynchronous tasks, such as sending emails, that may temporarily fail but can be automatically retried later.

Jobs use the Rails Active Job framework. Active Job is a common framework that allows jobs to be run on different job runner backends.

In the production environment, jobs are run using the Good Job backend. Jobs are stored in the database in the good_jobs table. Worker processes spawned by bin/good_job poll the table for new jobs to work.

In the development environment, jobs are run with an in-process thread pool. This will run jobs in the background, but will drop jobs when the server is restarted.

There is a very minimal admin dashboard for jobs at https://danbooru.donmai.us/jobs.

Danbooru also has periodic maintenance tasks that run in the background as cron jobs. These are different from the jobs in this directory. See app/logical/danbooru_maintenance.rb.

Usage

Start a pool of job workers:

RAILS_ENV=production bin/good_job start --max-threads=4

Examples

Spawn a job to be worked in the background. It will be worked as soon as a worker is available:

DeleteFavoritesJob.perform_later(user)

See also

External links