mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Add an option for watchdog to restart the child process
This commit is contained in:
parent
4217e65c5a
commit
4315853d95
@ -994,6 +994,11 @@ void BaseDaemon::setupWatchdog()
|
||||
if (argv0)
|
||||
original_process_name = argv0;
|
||||
|
||||
bool restart = false;
|
||||
const char * env_watchdog_restart = getenv("CLICKHOUSE_WATCHDOG_RESTART"); // NOLINT(concurrency-mt-unsafe)
|
||||
if (env_watchdog_restart && 0 == strcmp(env_watchdog_restart, "1"))
|
||||
restart = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
/// This pipe is used to synchronize notifications to the service manager from the child process
|
||||
@ -1141,14 +1146,14 @@ void BaseDaemon::setupWatchdog()
|
||||
logger().fatal("Child process was not exited normally by unknown reason.");
|
||||
}
|
||||
|
||||
/// Automatic restart is not enabled but you can play with it.
|
||||
#if 1
|
||||
_exit(WEXITSTATUS(status));
|
||||
#else
|
||||
logger().information("Will restart.");
|
||||
if (argv0)
|
||||
memcpy(argv0, original_process_name.c_str(), original_process_name.size());
|
||||
#endif
|
||||
if (restart)
|
||||
{
|
||||
logger().information("Will restart.");
|
||||
if (argv0)
|
||||
memcpy(argv0, original_process_name.c_str(), original_process_name.size());
|
||||
}
|
||||
else
|
||||
_exit(WEXITSTATUS(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user