Class: SimpleWorker::Runner
- Inherits:
-
Object
- Object
- SimpleWorker::Runner
- Defined in:
- lib/simpleworker/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #load(config = 'simpleworker.yml') ⇒ Object
- #run(cmd = 'rake') ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
5 6 7 |
# File 'lib/simpleworker/runner.rb', line 5 def initialize @workers = [] end |
Class Method Details
.load(config = 'simpleworker.yml') ⇒ Object
13 14 15 |
# File 'lib/simpleworker/runner.rb', line 13 def self.load(config = 'simpleworker.yml') new.load(config) end |
.run(cmd = 'rake') ⇒ Object
9 10 11 |
# File 'lib/simpleworker/runner.rb', line 9 def self.run(cmd = 'rake') new.load.run(cmd) end |
Instance Method Details
#load(config = 'simpleworker.yml') ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simpleworker/runner.rb', line 17 def load(config = 'simpleworker.yml') data = YAML.load( IO.read(config) ) data['workers'].each do |config| case config['type'] when 'ssh' @workers << SshWorker.create(config) else @workers << LocalWorker.create(config) end end self end |
#run(cmd = 'rake') ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/simpleworker/runner.rb', line 31 def run(cmd = 'rake') @workers.each do |worker| worker.cmd = cmd end start process stop rescue Interrupt stop rescue StandardError => e stop raise e end |