mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
#include "configReadClient.h"
|
|
|
|
#include <Poco/Util/Application.h>
|
|
#include <Poco/Util/LayeredConfiguration.h>
|
|
#include <Poco/File.h>
|
|
#include "ConfigProcessor.h"
|
|
|
|
namespace DB
|
|
{
|
|
bool configReadClient(Poco::Util::LayeredConfiguration & config, const std::string & home_path)
|
|
{
|
|
std::string config_path;
|
|
if (config.has("config-file"))
|
|
config_path = config.getString("config-file");
|
|
else if (Poco::File("./clickhouse-client.xml").exists())
|
|
config_path = "./clickhouse-client.xml";
|
|
else if (!home_path.empty() && Poco::File(home_path + "/.clickhouse-client/config.xml").exists())
|
|
config_path = home_path + "/.clickhouse-client/config.xml";
|
|
else if (Poco::File("/etc/clickhouse-client/config.xml").exists())
|
|
config_path = "/etc/clickhouse-client/config.xml";
|
|
|
|
if (!config_path.empty())
|
|
{
|
|
ConfigProcessor config_processor(config_path);
|
|
auto loaded_config = config_processor.loadConfig();
|
|
config.add(loaded_config.configuration);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|