| 125 | } |
| 126 | |
| 127 | void Keeper::createServer(const std::string & listen_host, const char * port_name, bool listen_try, CreateServerFunc && func) const |
| 128 | { |
| 129 | /// For testing purposes, user may omit tcp_port or http_port or https_port in configuration file. |
| 130 | if (!config().has(port_name)) |
| 131 | return; |
| 132 | |
| 133 | auto port = config().getInt(port_name); |
| 134 | try |
| 135 | { |
| 136 | func(static_cast<UInt16>(port)); |
| 137 | } |
| 138 | catch (const Poco::Exception &) |
| 139 | { |
| 140 | if (listen_try) |
| 141 | { |
| 142 | LOG_WARNING(&logger(), "Listen [{}]:{} failed: {}. If it is an IPv6 or IPv4 address and your host has disabled IPv6 or IPv4, " |
| 143 | "then consider to " |
| 144 | "specify not disabled IPv4 or IPv6 address to listen in <listen_host> element of configuration " |
| 145 | "file. Example for disabled IPv6: <listen_host>0.0.0.0</listen_host> ." |
| 146 | " Example for disabled IPv4: <listen_host>::</listen_host>", |
| 147 | listen_host, port, getCurrentExceptionMessage(false)); |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | throw Exception(ErrorCodes::NETWORK_ERROR, "Listen [{}]:{} failed: {}", listen_host, port, getCurrentExceptionMessage(false)); |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | void Keeper::uninitialize() |
| 157 | { |
nothing calls this directly
no test coverage detected