| 3616 | } |
| 3617 | |
| 3618 | void Server::createServers( |
| 3619 | Poco::Util::AbstractConfiguration & config, |
| 3620 | const ServerSettings & server_settings, |
| 3621 | const Strings & listen_hosts, |
| 3622 | bool listen_try, |
| 3623 | Poco::ThreadPool & server_pool, |
| 3624 | AsynchronousMetrics & async_metrics, |
| 3625 | std::vector<ProtocolServerAdapter> & servers, |
| 3626 | bool start_servers, |
| 3627 | const ServerType & server_type) |
| 3628 | { |
| 3629 | const Settings & settings = global_context->getSettingsRef(); |
| 3630 | |
| 3631 | Poco::Net::HTTPServerParams::Ptr http_params = new Poco::Net::HTTPServerParams; |
| 3632 | http_params->setTimeout(settings[Setting::http_receive_timeout]); |
| 3633 | http_params->setKeepAliveTimeout(global_context->getServerSettings()[ServerSetting::keep_alive_timeout]); |
| 3634 | http_params->setMaxKeepAliveRequests(static_cast<int>(global_context->getServerSettings()[ServerSetting::max_keep_alive_requests])); |
| 3635 | http_params->setMaxQueued(server_settings[ServerSetting::listen_backlog]); |
| 3636 | |
| 3637 | Poco::Util::AbstractConfiguration::Keys protocols; |
| 3638 | config.keys("protocols", protocols); |
| 3639 | |
| 3640 | const TCPServerConnectionFilter::Ptr & connection_filter = new TCPServerConnectionFilter{[&]() |
| 3641 | { |
| 3642 | return !ProfileEvents::checkCPUOverload(global_context->getServerSettings()[ServerSetting::os_cpu_busy_time_threshold], |
| 3643 | global_context->getMinOSCPUWaitTimeRatioToDropConnection(), |
| 3644 | global_context->getMaxOSCPUWaitTimeRatioToDropConnection(), |
| 3645 | /*should_throw*/ false); |
| 3646 | }}; |
| 3647 | |
| 3648 | for (const auto & protocol : protocols) |
| 3649 | { |
| 3650 | if (!server_type.shouldStart(ServerType::Type::CUSTOM, protocol)) |
| 3651 | continue; |
| 3652 | |
| 3653 | std::string prefix = "protocols." + protocol + "."; |
| 3654 | std::string port_name = prefix + "port"; |
| 3655 | std::string description {"<undefined> protocol"}; |
| 3656 | if (config.has(prefix + "description")) |
| 3657 | description = config.getString(prefix + "description"); |
| 3658 | |
| 3659 | if (!config.has(prefix + "port")) |
| 3660 | continue; |
| 3661 | |
| 3662 | std::vector<std::string> hosts; |
| 3663 | if (config.has(prefix + "host")) |
| 3664 | hosts.push_back(config.getString(prefix + "host")); |
| 3665 | else |
| 3666 | hosts = listen_hosts; |
| 3667 | |
| 3668 | for (const auto & host : hosts) |
| 3669 | { |
| 3670 | bool is_secure = false; |
| 3671 | auto stack = buildProtocolStackFromConfig(config, server_settings, protocol, http_params, async_metrics, is_secure); |
| 3672 | |
| 3673 | if (stack->empty()) |
| 3674 | throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "Protocol '{}' stack empty", protocol); |
| 3675 |
nothing calls this directly
no test coverage detected