Allow to enable or disable watchdog via env var

This commit is contained in:
Alexey Milovidov 2021-01-23 23:58:36 +03:00
parent ab6343ff1f
commit 8d335b1490

View File

@ -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
{