MCPcopy Create free account
hub / github.com/apache/trafficserver / initialize_jsonrpc_server

Function initialize_jsonrpc_server

src/traffic_server/traffic_server.cc:726–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724}
725
726std::tuple<bool, std::string>
727initialize_jsonrpc_server()
728{
729 std::tuple<bool, std::string> ok{true, {}};
730 auto filePath = RecConfigReadConfigPath("proxy.config.jsonrpc.filename", ts::filename::JSONRPC);
731
732 auto serverConfig = rpc::config::RPCConfig{};
733 serverConfig.load_from_file(filePath);
734 if (!serverConfig.is_enabled()) {
735 Dbg(dbg_ctl_rpc_init, "JSONRPC Disabled");
736 return ok;
737 }
738
739 // create and start the server.
740 try {
741 jsonrpcServer = new rpc::RPCServer{serverConfig};
742 jsonrpcServer->start_thread(TSThreadInit, TSThreadDestroy);
743 } catch (std::exception const &ex) {
744 // Only the constructor throws, so if we are here there should be no
745 // jsonrpcServer object.
746 ink_assert(jsonrpcServer == nullptr);
747 std::string msg;
748 return {false, swoc::bwprint(msg, "Server failed: '{}'", ex.what())};
749 }
750 // Register admin handlers.
751 rpc::admin::register_admin_jsonrpc_handlers();
752 Dbg(dbg_ctl_rpc_init, "JSONRPC. Public admin handlers registered.");
753
754 return ok;
755}
756
757#define CMD_ERROR -2 // serious error, exit maintenance mode
758#define CMD_FAILED -1 // error, but recoverable

Callers 1

mainFunction · 0.85

Calls 6

RecConfigReadConfigPathFunction · 0.85
start_threadMethod · 0.80
load_from_fileMethod · 0.45
is_enabledMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected