コード例 #1
0
int main() {
    RpcServer server;
    RpcServerOptions option;
    option.net_threads_num = 1;
    option.worker_threads_num = 1;
    server.set_options(option);

    comcfg::Configure conf;
    if (conf.load("./conf", "rpc_server.conf") != 0) {
        std::cerr << "load conf/rpc_server.conf fail" << std::endl;
    }
    comlog_init(conf["log"]);

    EchoServiceImpl echo_service_impl;
    if (server.RegisterService(&echo_service_impl) != 0) {
        std::cerr << "register service fail" << std::endl;
        return -1;
    }

    if (server.Start("127.0.0.1:60006")) {
        std::cerr << "start server fail" << std::endl;
        return -1;
    }

    return server.WaitForStop();
}