lib/remote_run/runner.rb in remote_run-0.1.1 vs lib/remote_run/runner.rb in remote_run-0.1.2

- old
+ new

@@ -21,12 +21,10 @@ start_tasks wait_for_tasks_to_finish handle_results end - private - def setup_unlock_on_exit at_exit do @configuration.hosts.each do |host| begin host.unlock @@ -35,13 +33,11 @@ end end end def start_ssh_master_connections - @configuration.hosts.each do |host| - host.start_ssh_master_connection - end + @host_manager.start_ssh_master_connections end def sync_working_copy_to_temp_location log("Creating temporary copy of #{@configuration.local_path} in #{@configuration.temp_path}...") excludes = @configuration.exclude.map { |dir| "--exclude '#{dir}'"} @@ -82,13 +78,15 @@ status_code end def start_task(host) task = @task_manager.find_task - @children << fork do + task.pid = fork do start_forked_task(host, task) end + task.host = host + @children << task end def start_forked_task(host, task) begin this_host = host.dup @@ -127,14 +125,18 @@ highline.say(highline.color("[Remote :: #{@configuration.identifier} :: #{run_time}] #{message}", color)) end end def check_for_finished - @children.each do |child_pid| + @children.each do |task| + child_pid = task.pid if task_is_finished?(child_pid) - @failed << child_pid unless $?.success? + unless $?.success? + @failed << child_pid + log("Task '#{task.command}' failed on #{task.host.hostname}") + end @results << $?.exitstatus - @children.delete(child_pid) + @children.delete(task) end end end def task_is_finished?(pid)