From 8d335b1490591db37cd3722e9825dd04c1fe40d3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 23 Jan 2021 23:58:36 +0300 Subject: [PATCH] Allow to enable or disable watchdog via env var --- programs/server/Server.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 94cd6854f78..2bb5181d348 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -109,8 +109,20 @@ int mainEntryClickHouseServer(int argc, char ** argv) /// Do not fork separate process from watchdog if we attached to terminal. /// Otherwise it breaks gdb usage. - if (argc > 0 && !isatty(STDIN_FILENO) && !isatty(STDOUT_FILENO) && !isatty(STDERR_FILENO)) - app.shouldSetupWatchdog(argv[0]); + /// Can be overridden by environment variable (cannot use server config at this moment). + if (argc > 0) + { + const char * env_watchdog = getenv("CLICKHOUSE_WATCHDOG_ENABLE"); + if (env_watchdog) + { + if (0 == strcmp(env_watchdog, "1")) + app.shouldSetupWatchdog(argv[0]); + + /// Other values disable watchdog explicitly. + } + else if (!isatty(STDIN_FILENO) && !isatty(STDOUT_FILENO) && !isatty(STDERR_FILENO)) + app.shouldSetupWatchdog(argv[0]); + } try {