configuration options for the master to set the number of runners and workers. all local for now

This commit is contained in:
Nick Gauthier 2010-01-29 13:39:29 -05:00
parent c8d833d1d3
commit 0a60223e6a
1 changed files with 13 additions and 11 deletions

View File

@ -11,11 +11,14 @@ module Hydra #:nodoc:
# * An array of test files to be run. These should be relative paths from
# the root of the project, since they may be run on different machines
# which may have different paths.
# * :workers
# * An array of hashes. Each hash should be the configuration options
# for a worker.
def initialize(opts = { })
@files = opts.fetch(:files) { [] }
@workers = []
@listeners = []
boot_workers
boot_workers(opts.fetch(:workers) { [ {:runners => 1} ] } )
process_messages
end
@ -35,18 +38,17 @@ module Hydra #:nodoc:
private
def boot_workers
# simple on worker method for now
# TODO: read config
def boot_workers(workers)
workers.each do |w|
pipe = Hydra::Pipe.new
child = Process.fork do
pipe.identify_as_child
# TODO num runners opt in next line
Hydra::Worker.new(:io => pipe, :runners => 1)
Hydra::Worker.new(:io => pipe, :runners => w[:runners])
end
pipe.identify_as_parent
@workers << { :pid => child, :io => pipe, :idle => false }
end
end
def process_messages
@running = true