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

Returns a new instance of Launcher.



9
10
11
12
13
# File 'lib/sidekiq/launcher.rb', line 9

def initialize(options)
  @options = options
  @manager = Sidekiq::Manager.new(options)
  @poller  = Sidekiq::Scheduled::Poller.new
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



8
9
10
# File 'lib/sidekiq/launcher.rb', line 8

def manager
  @manager
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/sidekiq/launcher.rb', line 8

def options
  @options
end

#pollerObject (readonly)

Returns the value of attribute poller.



8
9
10
# File 'lib/sidekiq/launcher.rb', line 8

def poller
  @poller
end

Instance Method Details

#procline(tag) ⇒ Object



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

def procline(tag)
  $0 = manager.procline(tag)
  manager.after(5) { procline(tag) }
end

#runObject



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

def run
  manager.async.start
  poller.async.poll(true)
end

#stopObject



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

def stop
  poller.async.terminate if poller.alive?
  manager.async.stop(:shutdown => true, :timeout => options[:timeout])
  manager.wait(:shutdown)
end