Class: Beez::Supervisor

Inherits:
Object
  • Object
show all
Defined in:
lib/beez/supervisor.rb

Instance Method Summary collapse

Constructor Details

#initializeSupervisor

Returns a new instance of Supervisor.



5
6
7
# File 'lib/beez/supervisor.rb', line 5

def initialize
  @processors = []
end

Instance Method Details

#quietObject



16
17
18
19
# File 'lib/beez/supervisor.rb', line 16

def quiet
  logger.info 'Terminating workers'
  @processors.each(&:stop)
end

#startObject



9
10
11
12
13
14
# File 'lib/beez/supervisor.rb', line 9

def start
  @processors = workers.map do |worker_class|
    processor = ::Beez::Processor.new(worker_class: worker_class)
    processor.start
  end
end

#stop(timeout: ::Beez.config.timeout) ⇒ Object



21
22
23
24
25
# File 'lib/beez/supervisor.rb', line 21

def stop(timeout: ::Beez.config.timeout)
  quiet
  logger.info "Pausing #{timeout}s to allow workers to finish..."
  sleep timeout
end