lib/good_job/capsule.rb in good_job-4.5.1 vs lib/good_job/capsule.rb in good_job-4.6.0
- old
+ new
@@ -22,10 +22,11 @@
@started_at = nil
@mutex = Mutex.new
@shared_executor = GoodJob::SharedExecutor.new
@tracker = GoodJob::CapsuleTracker.new(executor: @shared_executor)
+ @lower_thread_priority = nil
self.class.instances << self
end
# Start the capsule once. After a shutdown, {#restart} must be used to start again.
@@ -36,11 +37,13 @@
@mutex.synchronize do
return unless startable?(force: force)
@notifier = GoodJob::Notifier.new(enable_listening: configuration.enable_listen_notify, capsule: self, executor: @shared_executor)
@poller = GoodJob::Poller.new(poll_interval: configuration.poll_interval)
- @multi_scheduler = GoodJob::MultiScheduler.from_configuration(configuration, capsule: self, warm_cache_on_initialize: true)
+ @multi_scheduler = GoodJob::MultiScheduler.from_configuration(configuration, capsule: self, warm_cache_on_initialize: true).tap do |multischeduler|
+ multischeduler.lower_thread_priority = @lower_thread_priority unless @lower_thread_priority.nil?
+ end
@notifier.recipients.push([@multi_scheduler, :create_thread])
@poller.recipients.push(-> { @multi_scheduler.create_thread({ fanout: true }) })
@cron_manager = GoodJob::CronManager.new(configuration.cron_entries, start_on_initialize: true, executor: @shared_executor) if configuration.enable_cron?
@startable = false
@@ -106,9 +109,14 @@
# UUID for this capsule; to be used for inspection (not directly for locking jobs).
# @return [String]
def process_id
@tracker.process_id
+ end
+
+ def lower_thread_priority=(value)
+ @lower_thread_priority = value
+ @multi_scheduler&.lower_thread_priority = value
end
private
def configuration