diff --git a/github-fast-env.rb b/github-fast-env.rb index c44928d..5c02010 100755 --- a/github-fast-env.rb +++ b/github-fast-env.rb @@ -125,6 +125,8 @@ $control_socket.puts "ready" read_ios = [$control_socket, $stdin, pipes["stdout"], pipes["stderr"]] +exit_code = "unknown" + while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) or read_ios.include?(pipes["stderr"]) log "trace", read_ios.inspect @@ -150,6 +152,10 @@ while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) o if command != "done" log "error", "malformed response from github-fast-envd" end + + if !arguments.empty? + exit_code = arguments[0] + end else log "warn", "received input from unknown stream" end @@ -161,3 +167,9 @@ while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) o read_ios = read_ios.select {|x| not x.closed?} end + +exit_code_is_numeric = Integer(exit_code) != nil rescue false + +if exit_code_is_numeric + exit Integer(exit_code) +end diff --git a/github-fast-envd.rb b/github-fast-envd.rb index ed7256d..a27f74e 100755 --- a/github-fast-envd.rb +++ b/github-fast-envd.rb @@ -109,6 +109,8 @@ while true original_stdout = $stdout.dup original_stderr = $stderr.dup + exit_code = "unknown" + begin stdin = open_pipe(connection_id, "stdin") control_socket.puts "stdin #{stdin}" @@ -145,6 +147,9 @@ while true begin load script_path, true + rescue SystemExit => error + original_stderr.puts " exit code: #{error.status}" + exit_code = error.status rescue => error $stdin = original_stdin $stdout = original_stdout @@ -176,7 +181,7 @@ while true end begin - control_socket.puts "done" + control_socket.puts "done #{exit_code}" rescue end control_socket.close