| 148 | |
| 149 | #if defined(__linux__) || defined(__mac_tablet__) |
| 150 | void StartNameServer() { |
| 151 | SetupLog(); |
| 152 | std::string real_endpoint; |
| 153 | GetRealEndpoint(&real_endpoint); |
| 154 | ::fedb::nameserver::NameServerImpl* name_server = |
| 155 | new ::fedb::nameserver::NameServerImpl(); |
| 156 | if (!name_server->Init(real_endpoint)) { |
| 157 | PDLOG(WARNING, "Fail to init"); |
| 158 | exit(1); |
| 159 | } |
| 160 | if (!name_server->RegisterName()) { |
| 161 | PDLOG(WARNING, "Fail to register name"); |
| 162 | exit(1); |
| 163 | } |
| 164 | brpc::ServerOptions options; |
| 165 | options.num_threads = FLAGS_thread_pool_size; |
| 166 | brpc::Server server; |
| 167 | if (server.AddService(name_server, brpc::SERVER_DOESNT_OWN_SERVICE) != 0) { |
| 168 | PDLOG(WARNING, "Fail to add service"); |
| 169 | exit(1); |
| 170 | } |
| 171 | if (real_endpoint.empty()) { |
| 172 | real_endpoint = FLAGS_endpoint; |
| 173 | } |
| 174 | if (server.Start(real_endpoint.c_str(), &options) != 0) { |
| 175 | PDLOG(WARNING, "Fail to start server"); |
| 176 | exit(1); |
| 177 | } |
| 178 | PDLOG(INFO, "start nameserver on endpoint %s with version %s", real_endpoint.c_str(), FEDB_VERSION.c_str()); |
| 179 | server.set_version(FEDB_VERSION.c_str()); |
| 180 | server.RunUntilAskedToQuit(); |
| 181 | } |
| 182 | |
| 183 | int THPIsEnabled() { |
| 184 | #if defined(__linux__) || defined(__mac_tablet__) |
no test coverage detected