MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / createServer

Method createServer

programs/server/Server.cpp:653–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651
652
653void Server::createServer(
654 Poco::Util::AbstractConfiguration & config,
655 const std::string & listen_host,
656 const char * port_name,
657 bool listen_try,
658 bool start_server,
659 std::vector<ProtocolServerAdapter> & servers,
660 CreateServerFunc && func) const
661{
662 if (DB::createServer(config, listen_host, port_name, listen_try, start_server, servers, std::move(func), &logger()))
663 {
664 /// Register the configured port rather than the actual bound port. `getServerPort` keeps a
665 /// single value per `port_name`, so with `tcp_port=0` (OS-assigned) and several `listen_host`
666 /// values (e.g. the default `::1` + `127.0.0.1`) each host binds a distinct ephemeral port and
667 /// registering the actual port would let the last host overwrite the others, leaving
668 /// `getServerPort` pointing at a port that is not listening on the host a client uses. When the
669 /// configured port is non-zero it equals the bound port anyway, so this preserves the previous
670 /// behavior in all cases. (`clickhouse-local` registers the actual bound port because it needs
671 /// the OS-assigned value, but it rejects the ambiguous `port=0` + multiple `listen_host` combo.)
672 global_context->registerServerPort(port_name, static_cast<UInt16>(config.getInt(port_name)));
673 }
674}
675
676
677#if defined(OS_LINUX)

Callers

nothing calls this directly

Calls 4

createServerFunction · 0.85
loggerFunction · 0.85
registerServerPortMethod · 0.80
getIntMethod · 0.45

Tested by

no test coverage detected