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