diff --git a/base/application.cpp b/base/application.cpp index c17edeeb5..25c96a3a3 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -69,8 +69,6 @@ Application::~Application(void) m_ShuttingDown = true; - DynamicObject::DeactivateObjects(); - #ifdef _WIN32 WSACleanup(); #endif /* _WIN32 */ @@ -300,8 +298,6 @@ int Application::Run(int argc, char **argv) DynamicObject::FinishTx(); DynamicObject::DeactivateObjects(); - - assert(m_Instance == NULL); } catch (const exception& ex) { Logger::Write(LogCritical, "base", "---"); Logger::Write(LogCritical, "base", "Exception: " + Utility::GetTypeName(typeid(ex))); diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 41b9f8b50..4356cebad 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -45,6 +45,8 @@ int main(int argc, char **argv) lt_dlinit(); #endif /* _WIN32 */ + /* This must be done before calling any other functions + * in the base library. */ Application::SetMainThread(); #ifdef _WIN32 @@ -60,14 +62,13 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - String configFile = argv[2]; - String componentDirectory = Utility::DirName(Application::GetExePath(argv[0])) + "/../lib/icinga2"; Component::AddSearchDir(componentDirectory); DynamicObject::BeginTx(); /* load config file */ + String configFile = argv[2]; vector configItems = ConfigCompiler::CompileFile(configFile); Logger::Write(LogInformation, "icinga", "Executing config items..."); @@ -83,6 +84,8 @@ int main(int argc, char **argv) if (!app) throw_exception(runtime_error("Configuration must create an Application object.")); + /* The application class doesn't need to know about the "-c configFile" + * command-line arguments. */ return app->Run(argc - 2, &(argv[2])); }