Class: Cosmo::Engine
- Inherits:
-
Object
- Object
- Cosmo::Engine
- Defined in:
- lib/cosmo/engine.rb
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
- #run(type, options) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
Class Method Details
.instance ⇒ Object
16 17 18 |
# File 'lib/cosmo/engine.rb', line 16 def self.instance @instance ||= new end |
.run ⇒ Object
12 13 14 |
# File 'lib/cosmo/engine.rb', line 12 def self.run(...) instance.run(...) end |
Instance Method Details
#run(type, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cosmo/engine.rb', line 26 def run(type, ) handler = Utils::Signal.trap(:INT, :TERM) Logger.info "Starting processing, hit Ctrl-C to stop" processor_classes = type && PROCESSORS.key?(type.to_sym) ? [PROCESSORS[type.to_sym]] : PROCESSORS.values @processors = processor_classes.map { _1.run(@pool, @running, ) } if @running.false? Logger.warn "Shutting down... (No processors are running)" return end signal = handler.wait Logger.info "Shutting down... (#{signal} received)" shutdown end |