Sha256: 21427acf301da36244033acb611e1b2d9eb4de45e724416d9f9a66f8ff2f0d04

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 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
        begin
          DeepTest.logger.debug "Loader Starting (#{$$})"
          passed = @runner.process_work_units
        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

13 entries across 13 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/process_orchestrator.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/process_orchestrator.rb
jperkins-deep_test-1.2.2 lib/deep_test/process_orchestrator.rb
jstorimer-deep-test-1.4.0 lib/deep_test/process_orchestrator.rb
jstorimer-deep-test-1.3.0 lib/deep_test/process_orchestrator.rb
jstorimer-deep-test-1.2.0 lib/deep_test/process_orchestrator.rb
jstorimer-deep-test-1.1.0 lib/deep_test/process_orchestrator.rb
jstorimer-deep-test-1.0.0 lib/deep_test/process_orchestrator.rb
deep_test-1.2.2 lib/deep_test/process_orchestrator.rb
deep_test-1.2.1 lib/deep_test/process_orchestrator.rb
deep_test-1.2.0 lib/deep_test/process_orchestrator.rb