Class: Sidekiq::Launcher

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/launcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Launcher

add cron poller and execute normal initialize of Sidekiq launcher



20
21
22
23
# File 'lib/sidekiq/launcher.rb', line 20

def initialize(options)
  @cron_poller  = Sidekiq::Cron::Poller.new
  old_initialize options
end

Instance Attribute Details

#cron_pollerObject (readonly)

Add cron poller to launcher



13
14
15
# File 'lib/sidekiq/launcher.rb', line 13

def cron_poller
  @cron_poller
end

Instance Method Details

#old_initializeObject

remember old initialize



17
# File 'lib/sidekiq/launcher.rb', line 17

alias_method :old_initialize, :initialize

#old_runObject

remember old run



27
# File 'lib/sidekiq/launcher.rb', line 27

alias_method :old_run, :run

#old_stopObject

remember old stop



37
# File 'lib/sidekiq/launcher.rb', line 37

alias_method :old_stop, :stop

#runObject

execute normal run of launcher and run cron poller



30
31
32
33
# File 'lib/sidekiq/launcher.rb', line 30

def run
  old_run
  cron_poller.async.poll(true)
end

#stopObject

execute normal stop of launcher and stop cron poller



40
41
42
43
# File 'lib/sidekiq/launcher.rb', line 40

def stop
  cron_poller.async.terminate if poller.alive?
  old_stop
end