You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.cc 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "master/server.h"
  17. #include <atomic>
  18. #include <future>
  19. #include <memory>
  20. #include <string>
  21. #include <utility>
  22. #include <vector>
  23. #include "common/proto_tensor.h"
  24. #include "common/serving_common.h"
  25. #include "common/exit_handle.h"
  26. #include "master/dispacther.h"
  27. #include "master/grpc/grpc_process.h"
  28. #include "master/restful/http_process.h"
  29. #include "worker/context.h"
  30. namespace mindspore {
  31. namespace serving {
  32. Status Server::StartGrpcServer(const std::string &ip, uint32_t grpc_port, int max_msg_mb_size) {
  33. if (max_msg_mb_size > gRpcMaxMBMsgSize) {
  34. MSI_LOG_WARNING << "The maximum Serving gRPC message size is 512MB and will be updated from " << max_msg_mb_size
  35. << "MB to 512MB";
  36. max_msg_mb_size = gRpcMaxMBMsgSize;
  37. }
  38. return grpc_server_.Start(std::make_shared<MSServiceImpl>(dispatcher_), ip, grpc_port, max_msg_mb_size,
  39. "Serving gRPC");
  40. }
  41. Status Server::StartGrpcMasterServer(const std::string &ip, uint32_t grpc_port) {
  42. return grpc_manager_server_.Start(std::make_shared<MSMasterImpl>(dispatcher_), ip, grpc_port, -1, "Master");
  43. }
  44. Status Server::StartRestfulServer(const std::string &ip, uint32_t restful_port, int max_msg_mb_size,
  45. int time_out_second) {
  46. return restful_server_.Start(ip, restful_port, max_msg_mb_size, time_out_second);
  47. }
  48. void Server::Clear() { dispatcher_->Clear(); }
  49. Server::Server() = default;
  50. Server &Server::Instance() {
  51. static Server server;
  52. ExitHandle::Instance().InitSignalHandle();
  53. return server;
  54. }
  55. Server::~Server() = default;
  56. } // namespace serving
  57. } // namespace mindspore

A lightweight and high-performance service module that helps MindSpore developers efficiently deploy online inference services in the production environment.