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

Function main

example/grpc_c++/server.cpp:48–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46};
47
48int main(int argc, char* argv[]) {
49 // Parse gflags. We recommend you to use gflags as well.
50 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
51
52 // Generally you only need one Server.
53 brpc::Server server;
54
55 GreeterImpl http_svc;
56
57 // Add services into server. Notice the second parameter, because the
58 // service is put on stack, we don't want server to delete it, otherwise
59 // use brpc::SERVER_OWNS_SERVICE.
60 if (server.AddService(&http_svc,
61 brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
62 LOG(ERROR) << "Fail to add http_svc";
63 return -1;
64 }
65
66 // Start the server.
67 brpc::ServerOptions options;
68 options.idle_timeout_sec = FLAGS_idle_timeout_s;
69 if (server.Start(FLAGS_port, &options) != 0) {
70 LOG(ERROR) << "Fail to start HttpServer";
71 return -1;
72 }
73
74 // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
75 server.RunUntilAskedToQuit();
76 return 0;
77}

Callers

nothing calls this directly

Calls 3

AddServiceMethod · 0.80
RunUntilAskedToQuitMethod · 0.80
StartMethod · 0.45

Tested by

no test coverage detected