| 323 | |
| 324 | |
| 325 | void LocalServer::initialize(Poco::Util::Application & self) |
| 326 | { |
| 327 | Poco::Util::Application::initialize(self); |
| 328 | |
| 329 | const char * home_path_cstr = getenv("HOME"); // NOLINT(concurrency-mt-unsafe) |
| 330 | if (home_path_cstr) |
| 331 | home_path = home_path_cstr; |
| 332 | |
| 333 | /// Load config files if exists |
| 334 | std::string config_path; |
| 335 | if (getClientConfiguration().has("config-file")) |
| 336 | config_path = getClientConfiguration().getString("config-file"); |
| 337 | else if (config_path.empty() && fs::exists("config.xml")) |
| 338 | config_path = "config.xml"; |
| 339 | else if (config_path.empty()) |
| 340 | config_path = getLocalConfigPath(home_path).value_or(""); |
| 341 | |
| 342 | if (fs::exists(config_path)) |
| 343 | { |
| 344 | ConfigProcessor config_processor(config_path); |
| 345 | ConfigProcessor::setConfigPath(fs::path(config_path).parent_path()); |
| 346 | auto loaded_config = config_processor.loadConfig(); |
| 347 | getClientConfiguration().add(loaded_config.configuration.duplicate(), PRIO_DEFAULT, false); |
| 348 | loaded_config_path = config_path; |
| 349 | } |
| 350 | |
| 351 | server_settings.loadSettingsFromConfig(config()); |
| 352 | |
| 353 | #if USE_JEMALLOC |
| 354 | Jemalloc::setup( |
| 355 | server_settings[ServerSetting::jemalloc_enable_global_profiler], |
| 356 | server_settings[ServerSetting::jemalloc_enable_background_threads], |
| 357 | server_settings[ServerSetting::jemalloc_max_background_threads_num], |
| 358 | server_settings[ServerSetting::jemalloc_collect_global_profile_samples_in_trace_log], |
| 359 | server_settings[ServerSetting::jemalloc_profiler_sampling_rate]); |
| 360 | #endif |
| 361 | |
| 362 | GlobalThreadPool::initialize( |
| 363 | server_settings[ServerSetting::max_thread_pool_size], |
| 364 | server_settings[ServerSetting::max_thread_pool_free_size], |
| 365 | server_settings[ServerSetting::thread_pool_queue_size]); |
| 366 | |
| 367 | #if USE_AZURE_BLOB_STORAGE |
| 368 | /// See the explanation near the same line in Server.cpp |
| 369 | GlobalThreadPool::instance().addOnDestroyCallback([] |
| 370 | { |
| 371 | Azure::Storage::_internal::XmlGlobalDeinitialize(); |
| 372 | }); |
| 373 | #endif |
| 374 | |
| 375 | getIOThreadPool().initialize( |
| 376 | server_settings[ServerSetting::max_io_thread_pool_size], |
| 377 | server_settings[ServerSetting::max_io_thread_pool_free_size], |
| 378 | server_settings[ServerSetting::io_thread_pool_queue_size]); |
| 379 | |
| 380 | const size_t active_parts_loading_threads = server_settings[ServerSetting::max_active_parts_loading_thread_pool_size]; |
| 381 | getActivePartsLoadingThreadPool().initialize( |
| 382 | active_parts_loading_threads, |
nothing calls this directly
no test coverage detected