lib/sidekiq_bus/adapter.rb in sidekiq-bus-0.8.0 vs lib/sidekiq_bus/adapter.rb in sidekiq-bus-0.8.1

- old
+ new

@@ -45,21 +45,29 @@ # set up. You may consider enabling dynamic schedules to keep all nodes up # to date if it ever changes. def setup_heartbeat!(queue_name) require 'sidekiq-scheduler' + ::Sidekiq.configure_server do |config| + config.on(:startup) { set_schedule(queue_name) } + end + end + + private + + def set_schedule(queue_name) ::Sidekiq.set_schedule( 'sidekiqbus_heartbeat', every: '1min', class: ::QueueBus::Worker.name, args: [ ::QueueBus::Util.encode('bus_class_proxy' => ::QueueBus::Heartbeat.name) ], queue: queue_name, description: 'Enqueues a heart beat every minute for the queue-bus' ) - # Must reload the schedule to make it present in memory - ::Sidekiq.reload_schedule! + + ::Sidekiq::Scheduler.instance.update_schedule unless ::Sidekiq::Scheduler.instance.dynamic end end end end