MCPcopy Create free account
hub / github.com/Icinga/icinga2 / LoadConfigFiles

Method LoadConfigFiles

lib/cli/daemonutility.cpp:240–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240bool DaemonUtility::LoadConfigFiles(const std::vector<std::string>& configs,
241 std::vector<ConfigItem::Ptr>& newItems,
242 const String& objectsFile, const String& varsfile)
243{
244 ActivationScope ascope;
245
246 if (!DaemonUtility::ValidateConfigFiles(configs, objectsFile)) {
247 ConfigCompilerContext::GetInstance()->CancelObjectsFile();
248 return false;
249 }
250
251 // After evaluating the top-level statements of the config files (happening in ValidateConfigFiles() above),
252 // prevent further modification of the global scope. This allows for a faster execution of the following steps
253 // as Freeze() disables locking as it's not necessary on a read-only data structure anymore.
254 ScriptGlobal::GetGlobals()->Freeze();
255
256 WorkQueue upq(25000, Configuration::Concurrency);
257 upq.SetName("DaemonUtility::LoadConfigFiles");
258 bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
259
260 if (!result) {
261 ConfigCompilerContext::GetInstance()->CancelObjectsFile();
262 return false;
263 }
264
265 try {
266 ScriptGlobal::WriteToFile(varsfile);
267 } catch (const std::exception& ex) {
268 Log(LogCritical, "cli", "Could not write vars file: " + DiagnosticInformation(ex, false));
269 Application::Exit(1);
270 }
271
272 ConfigCompilerContext::GetInstance()->FinishObjectsFile();
273
274 return true;
275}

Callers

nothing calls this directly

Calls 6

LogClass · 0.85
CancelObjectsFileMethod · 0.80
GetContextMethod · 0.80
FinishObjectsFileMethod · 0.80
FreezeMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected