MCPcopy Create free account
hub / github.com/apache/brpc / main

Function main

example/baidu_proxy_and_generic_call/proxy.cpp:112–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110} // namespace example
111
112int main(int argc, char* argv[]) {
113 // Parse gflags. We recommend you to use gflags as well.
114 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
115
116 // Generally you only need one Server.
117 brpc::Server server;
118
119 butil::EndPoint point;
120 if (!FLAGS_listen_addr.empty()) {
121 if (butil::str2endpoint(FLAGS_listen_addr.c_str(), &point) < 0) {
122 LOG(ERROR) << "Invalid listen address:" << FLAGS_listen_addr;
123 return -1;
124 }
125 } else {
126 point = butil::EndPoint(butil::IP_ANY, FLAGS_port);
127 }
128 // Start the server.
129 brpc::ServerOptions options;
130 // Add the baidu master service into server.
131 // Notice new operator, because server will delete it in dtor of Server.
132 options.baidu_master_service = new example::BaiduMasterServiceImpl();
133 options.idle_timeout_sec = FLAGS_idle_timeout_s;
134 if (server.Start(point, &options) != 0) {
135 LOG(ERROR) << "Fail to start EchoServer";
136 return -1;
137 }
138
139 // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
140 server.RunUntilAskedToQuit();
141 return 0;
142}

Callers

nothing calls this directly

Calls 6

str2endpointFunction · 0.85
EndPointClass · 0.85
RunUntilAskedToQuitMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected