diff --git a/lib/falcon/command/supervisor.rb b/lib/falcon/command/supervisor.rb index 1a6a81ae..a1bb1082 100644 --- a/lib/falcon/command/supervisor.rb +++ b/lib/falcon/command/supervisor.rb @@ -40,8 +40,8 @@ class Metrics < Samovar::Command # Send the metrics message to the supervisor and print the results. def call(stream) - stream.puts({please: 'metrics'}.to_json, separator: "\0") - response = JSON.parse(stream.gets("\0"), symbolize_names: true) + stream.puts({please: 'metrics'}.to_json, separator: "\0", chomp: true) + response = JSON.parse(stream.read_until("\0"), symbolize_names: true) $stdout.puts response end diff --git a/lib/falcon/service/supervisor.rb b/lib/falcon/service/supervisor.rb index 4711fc59..9e9ffde6 100644 --- a/lib/falcon/service/supervisor.rb +++ b/lib/falcon/service/supervisor.rb @@ -74,7 +74,7 @@ def setup(container) @bound_endpoint.accept do |peer| stream = ::IO::Stream(peer) - while message = stream.gets("\0") + while message = stream.read_until("\0") response = handle(JSON.parse(message, symbolize_names: true)) stream.puts(response.to_json, separator: "\0") end @@ -101,7 +101,7 @@ def invoke(command) stream.puts(command.to_json, separator: "\0") - response = JSON.parse(stream.gets("\0"), symbolize_names: true) + response = JSON.parse(stream.read_until("\0"), symbolize_names: true) return response end