Class: Shoryuken::Launcher

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Util
Defined in:
lib/shoryuken/launcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#elapsed, #fire_event, #logger, #unparse_queues, #watchdog, #worker_name

Constructor Details

#initializeLauncher


10
11
12
13
14
15
16
17
18
# File 'lib/shoryuken/launcher.rb', line 10

def initialize
  @condvar = Celluloid::Condition.new
  @manager = Shoryuken::Manager.new_link(@condvar)
  @fetcher = Shoryuken::Fetcher.new_link(manager)

  @done = false

  manager.fetcher = @fetcher
end

Instance Attribute Details

#managerObject

Returns the value of attribute manager


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

def manager
  @manager
end

Instance Method Details

#actor_died(actor, reason) ⇒ Object


37
38
39
40
41
# File 'lib/shoryuken/launcher.rb', line 37

def actor_died(actor, reason)
  return if @done
  logger.warn { 'Shoryuken died due to the following error, cannot recover, process exiting' }
  exit 1
end

#runObject


31
32
33
34
35
# File 'lib/shoryuken/launcher.rb', line 31

def run
  watchdog('Launcher#run') do
    manager.async.start
  end
end

#stop(options = {}) ⇒ Object


20
21
22
23
24
25
26
27
28
29
# File 'lib/shoryuken/launcher.rb', line 20

def stop(options = {})
  watchdog('Launcher#stop') do
    @done = true
    @fetcher.terminate if @fetcher.alive?

    manager.async.stop(shutdown: !!options[:shutdown], timeout: Shoryuken.options[:timeout])
    @condvar.wait
    manager.terminate
  end
end