diff --git a/dbms/programs/local/LocalServer.cpp b/dbms/programs/local/LocalServer.cpp index 330404aa2e6..3e3b249fe82 100644 --- a/dbms/programs/local/LocalServer.cpp +++ b/dbms/programs/local/LocalServer.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace DB @@ -497,6 +498,11 @@ void LocalServer::init(int argc, char ** argv) config().setString("logger.level", options["logger.level"].as()); if (options.count("ignore-error")) config().setBool("ignore-error", true); + + std::vector arguments; + for (int arg_num = 1; arg_num < argc; ++arg_num) + arguments.emplace_back(argv[arg_num]); + argsToConfig(arguments, config(), 100); } void LocalServer::applyCmdOptions() diff --git a/dbms/src/Interpreters/Context.cpp b/dbms/src/Interpreters/Context.cpp index 5e429c6ce06..a1b60e1e23b 100644 --- a/dbms/src/Interpreters/Context.cpp +++ b/dbms/src/Interpreters/Context.cpp @@ -1524,7 +1524,7 @@ UInt16 Context::getTCPPort() const auto lock = getLock(); auto & config = getConfigRef(); - return config.getInt("tcp_port"); + return config.getInt("tcp_port", DBMS_DEFAULT_PORT); } std::optional Context::getTCPPortSecure() const diff --git a/dbms/tests/queries/0_stateless/00557_remote_port.reference b/dbms/tests/queries/0_stateless/00557_remote_port.reference index c4f459c5fe7..6c44cd60a28 100644 --- a/dbms/tests/queries/0_stateless/00557_remote_port.reference +++ b/dbms/tests/queries/0_stateless/00557_remote_port.reference @@ -9,3 +9,5 @@ 0 0 0 +1 +1 diff --git a/dbms/tests/queries/0_stateless/00557_remote_port.sh b/dbms/tests/queries/0_stateless/00557_remote_port.sh index e2a736f02a8..f614f58d76d 100755 --- a/dbms/tests/queries/0_stateless/00557_remote_port.sh +++ b/dbms/tests/queries/0_stateless/00557_remote_port.sh @@ -24,3 +24,7 @@ $CLICKHOUSE_CLIENT -q "SELECT * FROM remote('${CLICKHOUSE_HOST}:${CLICKHOUSE_POR $CLICKHOUSE_CLIENT -q "SELECT * FROM remote(test_shard_localhost, system, one);" $CLICKHOUSE_CLIENT -q "SELECT * FROM remote(test_shard_localhost, system, one, 'default', '');" $CLICKHOUSE_CLIENT -q "SELECT * FROM cluster('test_shard_localhost', system, one);" + +# Actually tcp_port is not used because we query localhost and it is done without IPC into clickhouse-local itself. +$CLICKHOUSE_LOCAL --query "SELECT count() FROM remote('127.0.0.1', system.one)" +$CLICKHOUSE_LOCAL --query "SELECT count() FROM remote('127.0.0.1', system.one)" -- --tcp_port=59000 diff --git a/libs/libloggers/loggers/Loggers.h b/libs/libloggers/loggers/Loggers.h index 9090d5c3e7c..7b3c0860273 100644 --- a/libs/libloggers/loggers/Loggers.h +++ b/libs/libloggers/loggers/Loggers.h @@ -13,15 +13,14 @@ class AbstractConfiguration; class Loggers { public: - /// Строит необходимые логгеры void buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger, const std::string & cmd_name = ""); - /// Закрыть файлы с логами. При следующей записи, будут созданы новые файлы. + /// Close log files. On next log write files will be reopened. void closeLogs(Poco::Logger & logger); std::optional getLayer() const { - return layer; /// layer выставляется в классе-наследнике BaseDaemonApplication. + return layer; /// layer setted in inheritor class BaseDaemonApplication. } protected: diff --git a/libs/libloggers/loggers/OwnPatternFormatter.cpp b/libs/libloggers/loggers/OwnPatternFormatter.cpp index 7db71ed61ab..cd0f372fbfa 100644 --- a/libs/libloggers/loggers/OwnPatternFormatter.cpp +++ b/libs/libloggers/loggers/OwnPatternFormatter.cpp @@ -11,8 +11,8 @@ #include "Loggers.h" -OwnPatternFormatter::OwnPatternFormatter(const Loggers * daemon_, OwnPatternFormatter::Options options_) - : Poco::PatternFormatter(""), daemon(daemon_), options(options_) +OwnPatternFormatter::OwnPatternFormatter(const Loggers * loggers_, OwnPatternFormatter::Options options_) + : Poco::PatternFormatter(""), loggers(loggers_), options(options_) { } @@ -25,9 +25,9 @@ void OwnPatternFormatter::formatExtended(const DB::ExtendedLogMessage & msg_ext, /// For syslog: tag must be before message and first whitespace. /// This code is only used in Yandex.Metrika and unneeded in ClickHouse. - if ((options & ADD_LAYER_TAG) && daemon) + if ((options & ADD_LAYER_TAG) && loggers) { - auto layer = daemon->getLayer(); + auto layer = loggers->getLayer(); if (layer) { writeCString("layer[", wb); diff --git a/libs/libloggers/loggers/OwnPatternFormatter.h b/libs/libloggers/loggers/OwnPatternFormatter.h index 00a1b0a0313..0e100aa6f33 100644 --- a/libs/libloggers/loggers/OwnPatternFormatter.h +++ b/libs/libloggers/loggers/OwnPatternFormatter.h @@ -31,12 +31,12 @@ public: ADD_LAYER_TAG = 1 << 0 }; - OwnPatternFormatter(const Loggers * daemon_, Options options_ = ADD_NOTHING); + OwnPatternFormatter(const Loggers * loggers_, Options options_ = ADD_NOTHING); void format(const Poco::Message & msg, std::string & text) override; void formatExtended(const DB::ExtendedLogMessage & msg_ext, std::string & text); private: - const Loggers * daemon; + const Loggers * loggers; Options options; };