lib/meroku/tunnel.rb in meroku-2.0.7 vs lib/meroku/tunnel.rb in meroku-2.0.8
- old
+ new
@@ -12,18 +12,19 @@
end
def run(cmd)
@verbose=true
retries ||= 0
+ exit_code=nil
Net::SSH.start(@ip,
@username,
password: 'password',
keys: @keys,
verify_host_key: @verify_host_key,
timeout: 90) do |ssh|
channel = ssh.open_channel do |ch|
- STDERR.print cmd
+ STDERR.print "#{cmd}\n"
ch.exec cmd do |ch, success|
raise "could not execute command" unless success
ch.on_data do |c, data|
if @verbose
$stdout.print data
@@ -36,14 +37,19 @@
$stderr.print data
else
$stderr.print "."
end
end
+ ch.on_request("exit-status") do |ch, data|
+ exit_code = data.read_long
+ end
+
ch.on_close { print "\n" }
end
end
channel.wait
end
+ fail "Ssh command returned non-zero" if status != 0
rescue Errno::ECONNREFUSED => e
retry if (retries += 1) < 10
end
end
end