Break the hourly/daily/weekly/monthly maintenance tasks down into individual delayed jobs. This way if one task fails, it won't prevent other tasks from running. Also, jobs can be run in parallel, and can be individually retried if they fail.
37 lines
751 B
Ruby
37 lines
751 B
Ruby
module DanbooruMaintenance
|
|
module_function
|
|
|
|
def hourly
|
|
queue PruneUploadsJob
|
|
queue PrunePostsJob
|
|
queue PruneRateLimitsJob
|
|
queue RegeneratePostCountsJob
|
|
end
|
|
|
|
def daily
|
|
queue PruneDelayedJobsJob
|
|
queue PrunePostDisapprovalsJob
|
|
queue PruneBulkUpdateRequestsJob
|
|
queue PruneBansJob
|
|
queue BigqueryExportAllJob
|
|
queue VacuumDatabaseJob
|
|
end
|
|
|
|
def weekly
|
|
queue RetireTagRelationshipsJob
|
|
queue DmailInactiveApproversJob
|
|
end
|
|
|
|
def monthly
|
|
queue PruneApproversJob
|
|
end
|
|
|
|
def queue(job)
|
|
DanbooruLogger.info("Queueing #{job.name}")
|
|
job.perform_later
|
|
rescue Exception # rubocop:disable Lint/RescueException
|
|
DanbooruLogger.log(exception)
|
|
raise exception if Rails.env.test?
|
|
end
|
|
end
|