mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Fix object initialization order.
This commit is contained in:
parent
15fae2bf2a
commit
183135dbce
@ -86,6 +86,19 @@ static bool LoadConfigFiles(bool validateOnly)
|
|||||||
if (validateOnly)
|
if (validateOnly)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (Application::GetInstance()) {
|
||||||
|
Log(LogCritical, "icinga-app", "You must not manually create an Application object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>();
|
||||||
|
builder->SetType(Application::GetApplicationType());
|
||||||
|
builder->SetName("application");
|
||||||
|
ConfigItem::Ptr item = builder->Compile();
|
||||||
|
item->Register();
|
||||||
|
DynamicObject::Ptr dobj = item->Commit();
|
||||||
|
dobj->OnConfigLoaded();
|
||||||
|
|
||||||
ConfigItem::ActivateItems();
|
ConfigItem::ActivateItems();
|
||||||
|
|
||||||
ConfigItem::DiscardItems();
|
ConfigItem::DiscardItems();
|
||||||
@ -321,23 +334,6 @@ int main(int argc, char **argv)
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::Ptr app = Application::GetInstance();
|
|
||||||
|
|
||||||
if (app) {
|
|
||||||
Log(LogCritical, "icinga-app", "You must not manually create an Application object.");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>();
|
|
||||||
builder->SetType(Application::GetApplicationType());
|
|
||||||
builder->SetName("application");
|
|
||||||
ConfigItem::Ptr item = builder->Compile();
|
|
||||||
item->Register();
|
|
||||||
DynamicObject::Ptr dobj = item->Commit();
|
|
||||||
dobj->OnConfigLoaded();
|
|
||||||
dobj->Start();
|
|
||||||
app = static_pointer_cast<Application>(dobj);
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
@ -345,5 +341,5 @@ int main(int argc, char **argv)
|
|||||||
sigaction(SIGHUP, &sa, NULL);
|
sigaction(SIGHUP, &sa, NULL);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
return app->Run();
|
return Application::GetInstance()->Run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user