| 228 | } |
| 229 | |
| 230 | int mainEntryClickHouseServer(int argc, char ** argv) |
| 231 | { |
| 232 | DB::Server app; |
| 233 | if (jemallocOptionEnabled("opt.background_thread")) |
| 234 | { |
| 235 | LOG_ERROR(&app.logger(), |
| 236 | "jemalloc.background_thread was requested, " |
| 237 | "however ClickHouse uses percpu_arena and background_thread most likely will not give any benefits, " |
| 238 | "and also background_thread is not compatible with ClickHouse watchdog " |
| 239 | "(that can be disabled with CLICKHOUSE_WATCHDOG_ENABLE=0)"); |
| 240 | } |
| 241 | |
| 242 | /// Do not fork separate process from watchdog by default |
| 243 | /// Otherwise it breaks minidump and jeprof usage |
| 244 | /// Can be overridden by environment variable (cannot use server config at this moment). |
| 245 | if (argc > 0) |
| 246 | { |
| 247 | const char * env_watchdog = getenv("CLICKHOUSE_WATCHDOG_ENABLE"); |
| 248 | if (env_watchdog) |
| 249 | { |
| 250 | if (0 == strcmp(env_watchdog, "1")) |
| 251 | app.shouldSetupWatchdog(argv[0]); |
| 252 | |
| 253 | /// Other values disable watchdog explicitly. |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | try |
| 258 | { |
| 259 | return app.run(argc, argv); |
| 260 | } |
| 261 | catch (...) |
| 262 | { |
| 263 | std::cerr << DB::getCurrentExceptionMessage(true) << "\n"; |
| 264 | auto code = DB::getCurrentExceptionCode(); |
| 265 | return code ? code : 1; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | |
| 270 | namespace |
no test coverage detected