lib/rocket_job/jobs/housekeeping_job.rb in rocketjob-5.4.1 vs lib/rocket_job/jobs/housekeeping_job.rb in rocketjob-6.0.0.rc1
- old
+ new
@@ -33,11 +33,11 @@
self.description = "Cleans out historical jobs, and zombie servers."
# Runs every 15 minutes
self.cron_schedule = "*/15 * * * * UTC"
# Whether to destroy zombie servers automatically
- field :destroy_zombies, type: Boolean, default: true, user_editable: true, copy_on_restart: true
+ field :destroy_zombies, type: Mongoid::Boolean, default: true, user_editable: true, copy_on_restart: true
# Retention intervals in seconds.
# Set to nil to retain everything.
field :aborted_retention, type: Integer, default: 7.days, user_editable: true, copy_on_restart: true
field :completed_retention, type: Integer, default: 7.days, user_editable: true, copy_on_restart: true
@@ -52,15 +52,15 @@
end
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
- 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
+ return unless 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
end
end
end