jobs: switch from DelayedJob to GoodJob.
Switch the ActiveJob backend from DelayedJob to GoodJob. Differences: * The job worker is run with `bin/good_job start` instead of `bin/delayed_job`. * Jobs have an 8 hour timeout instead of a 4 hour timeout. * Jobs don't automatically retry on failure. * Finishing jobs are preserved and pruned after 7 days.
This commit is contained in:
@@ -3,15 +3,19 @@
|
||||
# The base class for all background jobs on Danbooru.
|
||||
#
|
||||
# @see https://guides.rubyonrails.org/active_job_basics.html
|
||||
# @see https://github.com/collectiveidea/delayed_job
|
||||
# @see https://github.com/bensheldon/good_job
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
class JobTimeoutError < StandardError; end
|
||||
|
||||
queue_as :default
|
||||
queue_with_priority 0
|
||||
|
||||
around_perform do |_job, block|
|
||||
CurrentUser.scoped(User.system, "127.0.0.1") do
|
||||
ApplicationRecord.without_timeout do
|
||||
block.call
|
||||
Timeout.timeout(8.hours, JobTimeoutError) do
|
||||
block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user