diff --git a/cpp/src/server/grpc_impl/GrpcMilvusServer.cpp b/cpp/src/server/grpc_impl/GrpcMilvusServer.cpp index a66897005275e187e3cf86dbd15b2176513f03d2..3b0927b438133a0e287ab7c52e66b458b1235023 100644 --- a/cpp/src/server/grpc_impl/GrpcMilvusServer.cpp +++ b/cpp/src/server/grpc_impl/GrpcMilvusServer.cpp @@ -25,6 +25,7 @@ #include #include + namespace zilliz { namespace milvus { namespace server { @@ -36,11 +37,11 @@ constexpr long MESSAGE_SIZE = -1; class NoReusePortOption : public ::grpc::ServerBuilderOption { public: - void UpdateArguments(::grpc::ChannelArguments* args) override { + void UpdateArguments(::grpc::ChannelArguments *args) override { args->SetInt(GRPC_ARG_ALLOW_REUSEPORT, 0); } - void UpdatePlugins(std::vector>* + void UpdatePlugins(std::vector> * plugins) override {} }; @@ -52,38 +53,32 @@ GrpcMilvusServer::StartService() { StopService(); } - try { - ServerConfig &config = ServerConfig::GetInstance(); - ConfigNode server_config = config.GetConfig(CONFIG_SERVER); - ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); - std::string address = server_config.GetValue(CONFIG_SERVER_ADDRESS, "127.0.0.1"); - int32_t port = server_config.GetInt32Value(CONFIG_SERVER_PORT, 19530); - - faiss::distance_compute_blas_threshold = engine_config.GetInt32Value(CONFIG_DCBT, 20); + ServerConfig &config = ServerConfig::GetInstance(); + ConfigNode server_config = config.GetConfig(CONFIG_SERVER); + ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); + std::string address = server_config.GetValue(CONFIG_SERVER_ADDRESS, "127.0.0.1"); + int32_t port = server_config.GetInt32Value(CONFIG_SERVER_PORT, 19530); - std::string server_address(address + ":" + std::to_string(port)); + faiss::distance_compute_blas_threshold = engine_config.GetInt32Value(CONFIG_DCBT, 20); - ::grpc::ServerBuilder builder; - builder.SetOption(std::unique_ptr<::grpc::ServerBuilderOption>(new NoReusePortOption)); - builder.SetMaxReceiveMessageSize(MESSAGE_SIZE); //default 4 * 1024 * 1024 - builder.SetMaxSendMessageSize(MESSAGE_SIZE); + std::string server_address(address + ":" + std::to_string(port)); - builder.SetCompressionAlgorithmSupportStatus(GRPC_COMPRESS_STREAM_GZIP, true); - builder.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_STREAM_GZIP); - builder.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_HIGH); + ::grpc::ServerBuilder builder; + builder.SetOption(std::unique_ptr<::grpc::ServerBuilderOption>(new NoReusePortOption)); + builder.SetMaxReceiveMessageSize(MESSAGE_SIZE); //default 4 * 1024 * 1024 + builder.SetMaxSendMessageSize(MESSAGE_SIZE); - GrpcRequestHandler service; + builder.SetCompressionAlgorithmSupportStatus(GRPC_COMPRESS_STREAM_GZIP, true); + builder.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_STREAM_GZIP); + builder.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_HIGH); - builder.AddListeningPort(server_address, ::grpc::InsecureServerCredentials()); - builder.RegisterService(&service); + GrpcRequestHandler service; - server = builder.BuildAndStart(); - server->Wait(); + builder.AddListeningPort(server_address, ::grpc::InsecureServerCredentials()); + builder.RegisterService(&service); - } catch (std::exception &ex) { - SERVER_LOG_ERROR << "Milvus server encounter exception: " << std::string(ex.what()) - << "Is another server instance running?"; - } + server = builder.BuildAndStart(); + server->Wait(); }