MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / initialize

Method initialize

src/Daemon/BaseDaemon.cpp:235–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233
234
235void BaseDaemon::initialize(Application & self)
236{
237 closeFDs();
238 ServerApplication::initialize(self);
239
240 /// now highest priority (lowest value) is PRIO_APPLICATION = -100, we want higher!
241 argsToConfig(argv(), config(), PRIO_APPLICATION - 100);
242
243 bool is_daemon = config().getBool("application.runAsDaemon", false);
244 if (is_daemon)
245 {
246 /** When creating pid file and looking for config, will search for paths relative to the working path of the program when started.
247 */
248 std::string path = fs::path(config().getString("application.path")).replace_filename("");
249 if (0 != chdir(path.c_str()))
250 throw Poco::Exception("Cannot change directory to " + path);
251 }
252
253 loadConfiguration();
254
255#if USE_JEMALLOC
256 Jemalloc::setup(
257 config().getBool(Jemalloc::config_enable_global_profiler, Jemalloc::default_enable_global_profiler),
258 config().getBool(Jemalloc::config_enable_background_threads, Jemalloc::default_enable_background_threads),
259 config().getUInt64(Jemalloc::config_max_background_threads_num, Jemalloc::default_max_background_threads_num),
260 config().getBool(Jemalloc::config_collect_global_profile_samples_in_trace_log, Jemalloc::default_collect_global_profile_samples_in_trace_log),
261 config().getUInt64(Jemalloc::config_profiler_sampling_rate, Jemalloc::default_profiler_sampling_rate));
262#endif
263
264 /// This must be done before creation of any files (including logs).
265 mode_t umask_num = 0027;
266 if (config().has("umask"))
267 {
268 std::string umask_str = config().getString("umask");
269 std::stringstream stream; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
270 stream << umask_str;
271 stream >> std::oct >> umask_num;
272 }
273 umask(umask_num);
274
275 ConfigProcessor(config_path).savePreprocessedConfig(loaded_config, ""
276#if USE_SSL
277 , true // skip loading encryption keys from ZK
278#endif
279 );
280
281
282#if defined(OS_LINUX)
283 /// Configure RLIMIT_SIGPENDING
284 /// (query profiler creates lots of timers - timer_create(), and this requires slot in pending signals)
285 if (auto pending_signals = config().getUInt64("pending_signals", 0); pending_signals > 0)
286 {
287 struct rlimit rlim{};
288 if (getrlimit(RLIMIT_SIGPENDING, &rlim))
289 throw Poco::Exception("Cannot getrlimit");
290
291 /// Only adjust if the current soft limit is below the requested value.
292 if (rlim.rlim_cur < pending_signals)

Callers 1

iFunction · 0.45

Calls 15

initializeFunction · 0.85
argsToConfigFunction · 0.85
chdirFunction · 0.85
loadConfigurationFunction · 0.85
ConfigProcessorClass · 0.85
loggerFunction · 0.85
tryCreateDirectoriesFunction · 0.85
commandNameMethod · 0.80
createDirectoryFunction · 0.70
ExceptionClass · 0.50

Tested by

no test coverage detected