From a24bcdcb743e844d9ad738b78cc98dcd9a778659 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Mon, 29 Sep 2014 09:33:41 -0700 Subject: WIP Infra - Update reporting in cloud.rb --- cloud.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cloud.rb b/cloud.rb index 840742b8c..0a6097ee7 100755 --- a/cloud.rb +++ b/cloud.rb @@ -8,6 +8,10 @@ require 'fileutils' require 'parseconfig' require 'open3' +# Don't buffer output to the client +STDOUT.sync = true +STDERR.sync = true + SCRIPT_DIR = File.expand_path(File.dirname(__FILE__)) module OpenShift @@ -102,6 +106,10 @@ module OpenShift @pipelining = true end + def all_eof(files) + files.find { |f| !f.eof }.nil? + end + def run_playbook(playbook) @inventory = 'inventory/hosts' if @inventory.nil? @@ -123,13 +131,15 @@ module OpenShift cmd = cmds.join(' ; ') - stdout, stderr, status = Open3.capture3(cmd) - if 0 != status.exitstatus - raise %Q[Following command failed with exit code: #{status.exitstatus} + pid = spawn(cmd, :out => $stdout, :err => $stderr, :close_others => true) + _, state = Process.wait2(pid) + + if 0 != state.exitstatus + raise %Q[Warning failed with exit code: #{state.exitstatus} + #{cmd} + extra_vars: #{@extra_vars.to_json} -stdout: #{stdout} -stderr: #{stderr} ] end ensure -- cgit v1.2.3