-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Ruby gRPC server does not stop gracefully after receiving SIGINT / SIGTERM #12189
Copy link
Copy link
Closed
Description
What version of gRPC and what language are you using?
Ruby, gRPC gem version: 1.4.5
What operating system (Linux, Windows, …) and version?
Mac OS X El Capitan 10.11.6
What runtime / compiler are you using (e.g. python version or version of gcc)
$ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15]
What did you do?
If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful.
require 'google/protobuf'
require 'grpc'
# The following definitions for EchoRequest, EchoReply, and EchoServer
# are taken straight from https://github.com/grpc/grpc/tree/master/src/ruby/end2end
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "echo.EchoRequest" do
optional :request, :string, 1
end
add_message "echo.EchoReply" do
optional :response, :string, 1
end
end
module Echo
EchoRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoRequest").msgclass
EchoReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoReply").msgclass
end
module Echo
module EchoServer
class Service
include GRPC::GenericService
self.marshal_class_method = :encode
self.unmarshal_class_method = :decode
self.service_name = 'echo.EchoServer'
rpc :Echo, EchoRequest, EchoReply
end
Stub = Service.rpc_stub_class
end
end
class EchoServerImpl < Echo::EchoServer::Service
# say_hello implements the SayHello rpc method.
def echo(echo_req, _)
Echo::EchoReply.new(response: echo_req.request)
end
end
s = GRPC::RpcServer.new
grpc_host = '0.0.0.0:50051'
begin
s.add_http2_port(
grpc_host,
:this_port_is_insecure
)
s.handle(EchoServerImpl)
s.run_till_terminated
rescue SignalException => e
puts e.inspect
s.stop
endInvoked using ruby grpc_test.rb (the name of the file).
What did you expect to see?
Upon sending a SIGTERM or SIGINT to the process, I would expect the process to exit gracefully.
What did you see instead?
Upon sending SIGTERM:
$ruby grpc_test.rb
#<SignalException: SIGTERM>
E0815 14:01:15.239863000 140735163437056 completion_queue.c:486] assertion failed: cqd->completed_head.next == (uintptr_t)&cqd->completed_head
Abort trap: 6
Upon sending SIGINT:
$ruby grpc_test.rb
^CInterrupt
E0815 14:00:59.510724000 140735163437056 completion_queue.c:486] assertion failed: cqd->completed_head.next == (uintptr_t)&cqd->completed_head
Abort trap: 6
Anything else we should know about your project / environment?
Not that I know of.
Reactions are currently unavailable