Class: Sidekiq::Launcher

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/cron/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



23
24
25
26
# File 'lib/sidekiq/cron/launcher.rb', line 23

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

Instance Attribute Details

#cron_pollerObject (readonly)

Add cron poller to launcher



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

def cron_poller
  @cron_poller
end

Instance Method Details

#old_initializeObject

remember old initialize



20
# File 'lib/sidekiq/cron/launcher.rb', line 20

alias_method :old_initialize, :initialize

#old_runObject

remember old run



30
# File 'lib/sidekiq/cron/launcher.rb', line 30

alias_method :old_run, :run

#old_stopObject

remember old stop



40
# File 'lib/sidekiq/cron/launcher.rb', line 40

alias_method :old_stop, :stop

#runObject

execute normal run of launcher and run cron poller



33
34
35
36
# File 'lib/sidekiq/cron/launcher.rb', line 33

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

#stopObject

execute normal stop of launcher and stop cron poller



43
44
45
46
# File 'lib/sidekiq/cron/launcher.rb', line 43

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