lib/hydra/master.rb in sskirby-hydra-0.21.0 vs lib/hydra/master.rb in sskirby-hydra-0.23.3

- old
+ new

@@ -1,8 +1,8 @@ require 'hydra/hash' require 'open3' -require 'tmpdir' +require 'hydra/tmpdir' require 'erb' require 'yaml' module Hydra #:nodoc: # Hydra class responsible for delegate work down to workers. @@ -12,10 +12,11 @@ class Master include Hydra::Messages::Master include Open3 traceable('MASTER') + attr_reader :failed_files # Create a new Master # # Options: # * :files @@ -52,10 +53,11 @@ opts.merge!(config_yml.stringify_keys!) end @files = Array(opts.fetch('files') { nil }) raise "No files, nothing to do" if @files.empty? @incomplete_files = @files.dup + @failed_files = [] @workers = [] @listeners = [] @event_listeners = Array(opts.fetch('listeners') { nil } ) @event_listeners.select{|l| l.is_a? String}.each do |l| @event_listeners.delete_at(@event_listeners.index(l)) @@ -64,11 +66,10 @@ end @verbose = opts.fetch('verbose') { false } @autosort = opts.fetch('autosort') { true } @sync = opts.fetch('sync') { nil } @environment = opts.fetch('environment') { 'test' } - @remote_require = opts.fetch('remote_require') {[]} if @autosort sort_files_from_report @event_listeners << Hydra::Listener::ReportGenerator.new(File.new(heuristic_file, 'w')) end @@ -115,10 +116,13 @@ send_file(worker) else @incomplete_files.delete_at(@incomplete_files.index(message.file)) trace "#{@incomplete_files.size} Files Remaining" @event_listeners.each{|l| l.file_end(message.file, message.output) } + unless message.output == '.' + @failed_files << message.file + end if @incomplete_files.empty? @workers.each do |worker| @event_listeners.each{|l| l.worker_end(worker) } end @@ -164,15 +168,13 @@ end def boot_ssh_worker(worker) sync = Sync.new(worker, @sync, @verbose) - custom_require = @remote_require.map {|r| " require '#{r}';"}.join(' ') - runners = worker.fetch('runners') { raise "You must specify the number of runners" } command = worker.fetch('command') { - "RAILS_ENV=#{@environment} ruby -e \"require 'rubygems'; require 'hydra';#{custom_require} Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :remote => '#{sync.connect}');\"" + "RAILS_ENV=#{@environment} ruby -e \"require 'rubygems'; require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose});\"" } trace "Booting SSH worker" ssh = Hydra::SSH.new("#{sync.ssh_opts} #{sync.connect}", sync.remote_dir, command) return { :io => ssh, :idle => false, :type => :ssh, :connect => sync.connect } @@ -233,9 +235,9 @@ end end end def heuristic_file - @heuristic_file ||= File.join(Dir.tmpdir, 'hydra_heuristics.yml') + @heuristic_file ||= File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml') end end end