Skip to content
Snippets Groups Projects
Commit 3c472d20 authored by Yang Gao's avatar Yang Gao
Browse files

Merge pull request #670 from ctiller/interop

Make interop server respond to sigint
parents 108f43b5 2f3e2ec8
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <sstream> #include <sstream>
#include <thread> #include <thread>
#include <signal.h>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
...@@ -80,6 +82,8 @@ namespace gflags { } ...@@ -80,6 +82,8 @@ namespace gflags { }
using namespace google; using namespace google;
using namespace gflags; using namespace gflags;
static bool got_sigint = false;
bool SetPayload(PayloadType type, int size, Payload* payload) { bool SetPayload(PayloadType type, int size, Payload* payload) {
PayloadType response_type = type; PayloadType response_type = type;
// TODO(yangg): Support UNCOMPRESSABLE payload. // TODO(yangg): Support UNCOMPRESSABLE payload.
...@@ -217,14 +221,17 @@ void RunServer() { ...@@ -217,14 +221,17 @@ void RunServer() {
} }
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str());
while (true) { while (!got_sigint) {
std::this_thread::sleep_for(std::chrono::seconds(5)); std::this_thread::sleep_for(std::chrono::seconds(5));
} }
} }
static void sigint_handler(int x) { got_sigint = true; }
int main(int argc, char** argv) { int main(int argc, char** argv) {
grpc_init(); grpc_init();
ParseCommandLineFlags(&argc, &argv, true); ParseCommandLineFlags(&argc, &argv, true);
signal(SIGINT, sigint_handler);
GPR_ASSERT(FLAGS_port != 0); GPR_ASSERT(FLAGS_port != 0);
RunServer(); RunServer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment