Class: Beez::Supervisor
- Inherits:
-
Object
- Object
- Beez::Supervisor
- Defined in:
- lib/beez/supervisor.rb
Instance Method Summary collapse
-
#initialize ⇒ Supervisor
constructor
A new instance of Supervisor.
- #quiet ⇒ Object
- #start ⇒ Object
- #stop(timeout: ::Beez.config.timeout) ⇒ Object
Constructor Details
#initialize ⇒ Supervisor
Returns a new instance of Supervisor.
5 6 7 |
# File 'lib/beez/supervisor.rb', line 5 def initialize @processors = [] end |
Instance Method Details
#quiet ⇒ Object
16 17 18 19 |
# File 'lib/beez/supervisor.rb', line 16 def quiet logger.info 'Terminating workers' @processors.each(&:stop) end |
#start ⇒ Object
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 |