| 515 | |
| 516 | int mainEntryClickHouseServer(int argc, char ** argv); |
| 517 | int mainEntryClickHouseServer(int argc, char ** argv) |
| 518 | { |
| 519 | DB::Server app; |
| 520 | |
| 521 | /// Do not fork separate process from watchdog if we attached to terminal. |
| 522 | /// Otherwise it breaks gdb usage. |
| 523 | /// Can be overridden by environment variable (cannot use server config at this moment). |
| 524 | if (argc > 0) |
| 525 | { |
| 526 | const char * env_watchdog = getenv("CLICKHOUSE_WATCHDOG_ENABLE"); // NOLINT(concurrency-mt-unsafe) |
| 527 | if (env_watchdog) |
| 528 | { |
| 529 | if (0 == strcmp(env_watchdog, "1")) |
| 530 | app.shouldSetupWatchdog(argv[0]); |
| 531 | |
| 532 | /// Other values disable watchdog explicitly. |
| 533 | } |
| 534 | else if (!isatty(STDIN_FILENO) && !isatty(STDOUT_FILENO) && !isatty(STDERR_FILENO)) |
| 535 | app.shouldSetupWatchdog(argv[0]); |
| 536 | } |
| 537 | |
| 538 | try |
| 539 | { |
| 540 | return app.run(argc, argv); |
| 541 | } |
| 542 | catch (...) |
| 543 | { |
| 544 | std::cerr << DB::getCurrentExceptionMessage(true) << "\n"; |
| 545 | auto code = DB::getCurrentExceptionCode(); |
| 546 | return static_cast<UInt8>(code) ? code : 1; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | namespace DB |
| 551 | { |
nothing calls this directly
no test coverage detected