Allow to set server timezone from configuration file [#CLICKHOUSE-2765].

This commit is contained in:
Alexey Milovidov 2017-01-22 15:53:24 +03:00
parent b1a5efffc0
commit 6ec9380510
2 changed files with 20 additions and 0 deletions

View File

@ -65,6 +65,17 @@
<!-- Default database. -->
<default_database>default</default_database>
<!-- Server time zone could be set here.
Time zone is used when converting between String and DateTime types,
when printing DateTime in text formats and parsing DateTime from text,
it is used in date and time related functions, if specific time zone was not passed as an argument.
Time zone is specified as identifier from IANA time zone database, like UTC or Africa/Abidjan.
If not specified, system time zone at server startup is used.
-->
<!-- <timezone>Europe/Moscow</timezone> -->
<!-- Configuration of clusters that could be used in Distributed tables.
https://clickhouse.yandex/reference_en.html#Distributed
-->

View File

@ -745,6 +745,15 @@ void BaseDaemon::initialize(Application& self)
}
}
/// This must be done before any usage of DateLUT. In particular, before any logging.
if (config().has("timezone"))
{
if (0 != setenv("TZ", config().getString("timezone").data(), 1))
throw Poco::Exception("Cannot setenv TZ variable");
tzset();
}
std::string log_path = config().getString("logger.log", "");
if (!log_path.empty())
log_path = Poco::Path(log_path).setFileName("").toString();