diff --git a/services/backup/src/server.cpp b/services/backup/src/server.cpp --- a/services/backup/src/server.cpp +++ b/services/backup/src/server.cpp @@ -1,30 +1,30 @@ #include "BackupServiceImpl.h" +#include "GlobalConstants.h" #include "GlobalTools.h" #include #include #include -#include namespace comm { namespace network { void RunServer() { - std::string server_address = "0.0.0.0:50051"; BackupServiceImpl backupService; grpc::EnableDefaultHealthCheckService(true); grpc::ServerBuilder builder; // Listen on the given address without any authentication mechanism. - builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); + builder.AddListeningPort( + SERVER_LISTEN_ADDRESS, grpc::InsecureServerCredentials()); // Register "service" as the instance through which we'll communicate with // clients. In this case it corresponds to an *synchronous* service. builder.RegisterService(&backupService); // Finally assemble the server. std::unique_ptr server(builder.BuildAndStart()); - LOG(INFO) << "Server listening"; + LOG(INFO) << "server listening at :" << SERVER_LISTEN_ADDRESS; // Wait for the server to shutdown. Note that some other thread must be // responsible for shutting down the server for this call to ever return. diff --git a/services/blob/src/server.cpp b/services/blob/src/server.cpp --- a/services/blob/src/server.cpp +++ b/services/blob/src/server.cpp @@ -1,26 +1,26 @@ #include "BlobServiceImpl.h" +#include "GlobalConstants.h" #include "GlobalTools.h" #include #include #include -#include namespace comm { namespace network { void RunServer() { - std::string server_address = "0.0.0.0:50051"; BlobServiceImpl blobService; grpc::EnableDefaultHealthCheckService(true); grpc::ServerBuilder builder; - builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); + builder.AddListeningPort( + SERVER_LISTEN_ADDRESS, grpc::InsecureServerCredentials()); builder.RegisterService(&blobService); std::unique_ptr server(builder.BuildAndStart()); - LOG(INFO) << "Server listening"; + LOG(INFO) << "server listening at :" << SERVER_LISTEN_ADDRESS; server->Wait(); } diff --git a/services/lib/src/GlobalConstants.h b/services/lib/src/GlobalConstants.h --- a/services/lib/src/GlobalConstants.h +++ b/services/lib/src/GlobalConstants.h @@ -24,5 +24,8 @@ const char ATTACHMENT_DELIMITER = ';'; +// gRPC Server +const std::string SERVER_LISTEN_ADDRESS = "0.0.0.0:50051"; + } // namespace network } // namespace comm diff --git a/services/tunnelbroker/src/Constants.h b/services/tunnelbroker/src/Constants.h --- a/services/tunnelbroker/src/Constants.h +++ b/services/tunnelbroker/src/Constants.h @@ -26,9 +26,6 @@ const std::regex SESSION_ID_FORMAT_REGEX( "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); -// gRPC Server -const std::string SERVER_LISTEN_ADDRESS = "0.0.0.0:50051"; - // AMQP (RabbitMQ) const std::string AMQP_FANOUT_EXCHANGE_NAME = "allBrokers"; // Message broker queue message TTL diff --git a/services/tunnelbroker/src/server.cpp b/services/tunnelbroker/src/server.cpp --- a/services/tunnelbroker/src/server.cpp +++ b/services/tunnelbroker/src/server.cpp @@ -4,6 +4,8 @@ #include "GlobalTools.h" #include "TunnelbrokerServiceImpl.h" +#include "GlobalConstants.h" + #include #include @@ -24,7 +26,7 @@ // clients. In this case it corresponds to an *synchronous* service. builder.RegisterService(&service); std::unique_ptr server(builder.BuildAndStart()); - LOG(INFO) << "gRPC Server listening at :" << SERVER_LISTEN_ADDRESS; + LOG(INFO) << "server listening at :" << SERVER_LISTEN_ADDRESS; // Wait for the server to shutdown. Note that some other thread must be // responsible for shutting down the server for this call to ever return. server->Wait();