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

Function main

example/backup_request_c++/server.cpp:79–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77} // namespace example
78
79int main(int argc, char* argv[]) {
80 // Parse gflags. We recommend you to use gflags as well.
81 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
82
83 // Generally you only need one Server.
84 brpc::Server server;
85
86 // Instance of your service.
87 example::SleepyEchoService echo_service_impl;
88
89 // Add the service into server. Notice the second parameter, because the
90 // service is put on stack, we don't want server to delete it, otherwise
91 // use brpc::SERVER_OWNS_SERVICE.
92 if (server.AddService(&echo_service_impl,
93 brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
94 LOG(ERROR) << "Fail to add service";
95 return -1;
96 }
97
98 // Start the server.
99 brpc::ServerOptions options;
100 options.idle_timeout_sec = FLAGS_idle_timeout_s;
101 if (server.Start(FLAGS_port, &options) != 0) {
102 LOG(ERROR) << "Fail to start EchoServer";
103 return -1;
104 }
105
106 // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
107 server.RunUntilAskedToQuit();
108 return 0;
109}

Callers

nothing calls this directly

Calls 3

AddServiceMethod · 0.80
RunUntilAskedToQuitMethod · 0.80
StartMethod · 0.45

Tested by

no test coverage detected