Class: Ringleader::Controller
- Inherits:
-
Object
- Object
- Ringleader::Controller
- Includes:
- Celluloid, Celluloid::Logger
- Defined in:
- lib/ringleader/controller.rb
Instance Method Summary collapse
- #app(name) ⇒ Object
- #apps ⇒ Object
-
#initialize(configs) ⇒ Controller
constructor
A new instance of Controller.
- #stop ⇒ Object
Constructor Details
#initialize(configs) ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 10 11 |
# File 'lib/ringleader/controller.rb', line 6 def initialize(configs) @apps = {} configs.each do |name, config| @apps[name] = App.new(config) end end |
Instance Method Details
#app(name) ⇒ Object
17 18 19 |
# File 'lib/ringleader/controller.rb', line 17 def app(name) @apps[name] end |
#apps ⇒ Object
13 14 15 |
# File 'lib/ringleader/controller.rb', line 13 def apps @apps.values.sort_by { |a| a.name } end |
#stop ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ringleader/controller.rb', line 21 def stop exit if @stopping # if ctrl-c called twice... @stopping = true info "shutting down..." @apps.values.map do |app| Thread.new { app.stop(:forever) if app.alive? } end.map(&:join) end |