lib/rocket_job/jobs/housekeeping_job.rb in rocketjob-3.4.2 vs lib/rocket_job/jobs/housekeeping_job.rb in rocketjob-3.4.3
- old
+ new
@@ -44,15 +44,20 @@
field :failed_retention, type: Integer, default: 14.days, user_editable: true, copy_on_restart: true
field :paused_retention, type: Integer, user_editable: true, copy_on_restart: true
field :queued_retention, type: Integer, user_editable: true, copy_on_restart: true
def perform
- RocketJob::Server.destroy_zombies if destroy_zombies
+ if destroy_zombies
+ # Cleanup zombie servers
+ RocketJob::Server.destroy_zombies
+ # Requeue jobs where the worker is in the zombie state and its server has gone away
+ RocketJob::ActiveWorker.requeue_zombies
+ end
- RocketJob::Job.aborted.where(created_at: {'$lte' => aborted_retention.seconds.ago}).destroy_all if aborted_retention
- RocketJob::Job.completed.where(created_at: {'$lte' => completed_retention.seconds.ago}).destroy_all if completed_retention
- RocketJob::Job.failed.where(created_at: {'$lte' => failed_retention.seconds.ago}).destroy_all if failed_retention
- RocketJob::Job.paused.where(created_at: {'$lte' => paused_retention.seconds.ago}).destroy_all if paused_retention
+ RocketJob::Job.aborted.where(completed_at: {'$lte' => aborted_retention.seconds.ago}).destroy_all if aborted_retention
+ RocketJob::Job.completed.where(completed_at: {'$lte' => completed_retention.seconds.ago}).destroy_all if completed_retention
+ RocketJob::Job.failed.where(completed_at: {'$lte' => failed_retention.seconds.ago}).destroy_all if failed_retention
+ RocketJob::Job.paused.where(completed_at: {'$lte' => paused_retention.seconds.ago}).destroy_all if paused_retention
RocketJob::Job.queued.where(created_at: {'$lte' => queued_retention.seconds.ago}).destroy_all if queued_retention
end
end
end