| 238 | } |
| 239 | |
| 240 | bool 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 | } |
nothing calls this directly
no test coverage detected