Class: RailsParallel::Runner::Parent

Inherits:
Object
  • Object
show all
Includes:
Forks
Defined in:
lib/rails_parallel/runner/parent.rb

Instance Method Summary collapse

Methods included from Forks

#before_exit, #check_status, #fork_and_run, #wait_any, #wait_for

Constructor Details

#initialize(params) ⇒ Parent

Returns a new instance of Parent.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rails_parallel/runner/parent.rb', line 24

def initialize(params)
  @name    = params[:name]
  @schema  = Schema.new(params[:schema])
  @options = params[:options]
  @files   = params[:files]
  @max_children = number_of_workers

  @timings = Timings.new

  @children  = []
  @launched  = 0
  @by_pid    = {}
  @by_socket = {}

  @result = Test::Unit::TestResult.new
  @faults = {}
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rails_parallel/runner/parent.rb', line 42

def run
  @schema.load_main_db

  pid = fork_and_run do
    status "RP: Preparing #{@name} ... "
    handle_options
    prepare
    puts "ready."

    puts "RP: Running #{@name}."
    start = Time.now
    begin
      launch_next_child
      monitor
    ensure
      @children.each(&:kill)
      output_result(Time.now - start)
    end
  end
  wait_for(pid)
end