Class: Kryten::Supervisor
- Inherits:
-
Object
- Object
- Kryten::Supervisor
- Defined in:
- lib/kryten/weaver.rb
Class Method Summary collapse
Class Method Details
.running? ⇒ Boolean
51 52 53 |
# File 'lib/kryten/weaver.rb', line 51 def self.running? @workers.detect(&:running) end |
.start(workers) ⇒ Object
31 32 33 34 |
# File 'lib/kryten/weaver.rb', line 31 def self.start(workers) start_workers(workers) sleep 1 while @started end |
.start_workers(workers) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/kryten/weaver.rb', line 36 def self.start_workers(workers) @workers = workers @started = true Signal.trap("INT", proc { self.stop }) workers.each(&:start_work) end |
.stop ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/kryten/weaver.rb', line 43 def self.stop if @started @workers.each(&:stop_work) sleep 1 while @workers.detect(&:running) @started = false end end |