当前位置:   article > 正文

triton-tritonserver的main函数_tritonserver option

tritonserver option

分析tritonserver的main函数。

  1. int
  2. main(int argc, char** argv)
  3. {
  4. // Parse command-line to create the options for the inference
  5. // server.
  6. TRITONSERVER_ServerOptions* server_options = nullptr;
  7. if (!Parse(&server_options, argc, argv)) {
  8. exit(1);
  9. }
  10. // Trace manager.
  11. triton::server::TraceManager* trace_manager;
  12. // Manager for shared memory blocks.
  13. auto shm_manager = std::make_shared<triton::server::SharedMemoryManager>();
  14. // Create the server...,其他参数要用这个返回值。
  15. TRITONSERVER_Server* server_ptr = nullptr;
  16. FAIL_IF_ERR(
  17. TRITONSERVER_ServerNew(&server_ptr, server_options), "creating server");
  18. FAIL_IF_ERR(
  19. TRITONSERVER_ServerOptionsDelete(server_options),
  20. "deleting server options");
  21. std::shared_ptr<TRITONSERVER_Server> server(
  22. server_ptr, TRITONSERVER_ServerDelete);
  23. // Configure and start tracing if specified on the command line.
  24. if (!StartTracing(&trace_manager)) {
  25. exit(1);
  26. }
  27. // Trap SIGINT and SIGTERM to allow server to exit gracefully
  28. TRITONSERVER_Error* signal_err = triton::server::RegisterSignalHandler();
  29. if (signal_err != nullptr) {
  30. LOG_TRITONSERVER_ERROR(signal_err, "failed to register signal handler");
  31. exit(1);
  32. }
  33. // Start the HTTP, GRPC, and metrics endpoints.
  34. //启动HTTP, GRPC,metrics监听程序
  35. if (!StartEndpoints(server, trace_manager, shm_manager)) {
  36. exit(1);
  37. }
  38. // Wait until a signal terminates the server...
  39. //开始进入循环。
  40. while (!triton::server::signal_exiting_) {
  41. // If enabled, poll the model repository to see if there have been
  42. // any changes.
  43. if (repository_poll_secs_ > 0) {
  44. //检测模型目录,比如配置文件有改动,会重载模型。
  45. LOG_TRITONSERVER_ERROR(
  46. TRITONSERVER_ServerPollModelRepository(server_ptr),
  47. "failed to poll model repository");
  48. }
  49. // Wait for the polling interval (or a long time if polling is not
  50. // enabled). Will be woken if the server is exiting.
  51. std::unique_lock<std::mutex> lock(triton::server::signal_exit_mu_);
  52. std::chrono::seconds wait_timeout(
  53. (repository_poll_secs_ == 0) ? 3600 : repository_poll_secs_);
  54. triton::server::signal_exit_cv_.wait_for(lock, wait_timeout);
  55. }
  56. TRITONSERVER_Error* stop_err = TRITONSERVER_ServerStop(server_ptr);
  57. // If unable to gracefully stop the server then Triton threads and
  58. // state are potentially in an invalid state, so just exit
  59. // immediately.
  60. if (stop_err != nullptr) {
  61. LOG_TRITONSERVER_ERROR(stop_err, "failed to stop server");
  62. exit(1);
  63. }
  64. // Stop tracing and the HTTP, GRPC, and metrics endpoints.
  65. StopEndpoints();
  66. StopTracing(&trace_manager);
  67. #ifdef TRITON_ENABLE_ASAN
  68. // Can invoke ASAN before exit though this is typically not very
  69. // useful since there are many objects that are not yet destructed.
  70. // __lsan_do_leak_check();
  71. #endif // TRITON_ENABLE_ASAN
  72. return 0;
  73. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/351789
推荐阅读
相关标签
  

闽ICP备14008679号