maintenance: break maintenance tasks into individual jobs.
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.
This commit is contained in:
8
app/jobs/vacuum_database_job.rb
Normal file
8
app/jobs/vacuum_database_job.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# A job that runs daily to vacuum the database. Spawned by {DanbooruMaintenance}.
|
||||
class VacuumDatabaseJob < ApplicationJob
|
||||
def perform
|
||||
# We can't perform vacuum inside a transaction. This happens during tests.
|
||||
return if ApplicationRecord.connection.transaction_open?
|
||||
ApplicationRecord.connection.execute("vacuum analyze")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user