Sha256: 78e1b44bd0586c86e48bf872233adf003fb20fe24633d210cef989ca6caf4b84

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 KB

Contents

module DeepTest
  class ProcessOrchestrator
    def self.run(options, workers, runner)
      new(options, workers, runner).run
    end
    
    def initialize(options, workers, runner)
      @options = options
      @runner = runner
      @workers = workers
    end
    
    def run(exit_when_done = true)
      passed = false

      begin
        server = Server.start(@options)
        @options.new_listener_list.before_starting_workers
        @workers.start_all(server)
        begin
          DeepTest.logger.debug "Loader Starting (#{$$})"
          passed = @runner.process_work_units(server)
        ensure
          shutdown(server)
        end
      ensure
        DeepTest.logger.debug "ProcessOrchestrator: Stopping Server"
        Server.stop
      end

      Kernel.exit(passed ? 0 : 1) if exit_when_done
    end

    def shutdown(server)
      DeepTest.logger.debug "ProcessOrchestrator: Shutting Down"
      server.done_with_work

      first_exception = $!
      begin
        DeepTest.logger.debug "ProcessOrchestrator: Stopping Workers"
        @workers.stop_all
      rescue DRb::DRbConnError
        # Workers must have already stopped
      rescue Exception => e
        raise first_exception || e
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.10 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.11 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.12 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.13 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.14 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.7 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.8 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.9 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.15 lib/deep_test/process_orchestrator.rb