| 415 | } |
| 416 | |
| 417 | void Server::createServer(const std::string & listen_host, const char * port_name, bool listen_try, CreateServerFunc && func) const |
| 418 | { |
| 419 | /// For testing purposes, user may omit tcp_port or http_port or https_port in configuration file. |
| 420 | if (!config().has(port_name)) |
| 421 | return; |
| 422 | |
| 423 | auto port = config().getInt(port_name); |
| 424 | try |
| 425 | { |
| 426 | func(port); |
| 427 | global_context->registerServerPort(port_name, port); |
| 428 | } |
| 429 | catch (const Poco::Exception &) |
| 430 | { |
| 431 | std::string message = "Listen [" + listen_host + "]:" + std::to_string(port) + " failed: " + getCurrentExceptionMessage(false); |
| 432 | |
| 433 | if (listen_try) |
| 434 | { |
| 435 | LOG_WARNING(&logger(), "{}. If it is an IPv6 or IPv4 address and your host has disabled IPv6 or IPv4, then consider to " |
| 436 | "specify not disabled IPv4 or IPv6 address to listen in <listen_host> element of configuration " |
| 437 | "file. Example for disabled IPv6: <listen_host>0.0.0.0</listen_host> ." |
| 438 | " Example for disabled IPv4: <listen_host>::</listen_host>", |
| 439 | message); |
| 440 | } |
| 441 | else |
| 442 | { |
| 443 | throw Exception{message, ErrorCodes::NETWORK_ERROR}; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | void Server::uninitialize() |
| 449 | { |
nothing calls this directly
no test coverage detected