Class: Cloudmunda::Supervisor
- Inherits:
-
Object
- Object
- Cloudmunda::Supervisor
- Defined in:
- lib/cloudmunda/cli/supervisor.rb
Instance Method Summary collapse
-
#initialize ⇒ Supervisor
constructor
A new instance of Supervisor.
- #quiet ⇒ Object
- #start ⇒ Object
- #stop(timeout: ::Cloudmunda.timeout) ⇒ Object
Constructor Details
#initialize ⇒ Supervisor
Returns a new instance of Supervisor.
7 8 9 |
# File 'lib/cloudmunda/cli/supervisor.rb', line 7 def initialize @processors = [] end |
Instance Method Details
#quiet ⇒ Object
24 25 26 27 |
# File 'lib/cloudmunda/cli/supervisor.rb', line 24 def quiet logger.info 'Terminating workers' @processors.each(&:stop) end |
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cloudmunda/cli/supervisor.rb', line 11 def start workers.each do |worker_class| if ::Cloudmunda.env == 'development' && !worker_class.get_runs_in_development logger.info "Not starting a processor for worker #{worker_class.get_type} as it doesn't run in development." next end logger.info "Starting a processor for worker #{worker_class.get_type}" processor = ::Cloudmunda::Processor.new(worker_class: worker_class) @processors << processor.start end end |
#stop(timeout: ::Cloudmunda.timeout) ⇒ Object
29 30 31 32 33 |
# File 'lib/cloudmunda/cli/supervisor.rb', line 29 def stop(timeout: ::Cloudmunda.timeout) quiet logger.info "Pausing #{timeout}s to allow workers to finish..." sleep timeout end |