mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-20 12:14:44 +02:00
parent
975915bb6f
commit
ba49fd38e1
@ -31,9 +31,12 @@ using namespace icinga;
|
|||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
static po::variables_map g_AppParams;
|
static po::variables_map g_AppParams;
|
||||||
|
static vector<ConfigItem::WeakPtr> g_ConfigItems;
|
||||||
|
|
||||||
static bool LoadConfigFiles(void)
|
static bool LoadConfigFiles(void)
|
||||||
{
|
{
|
||||||
|
set<ConfigItem::Ptr> allItems;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BOOST_FOREACH(const String& configPath, g_AppParams["config"].as<vector<String> >()) {
|
BOOST_FOREACH(const String& configPath, g_AppParams["config"].as<vector<String> >()) {
|
||||||
vector<ConfigItem::Ptr> items;
|
vector<ConfigItem::Ptr> items;
|
||||||
@ -67,8 +70,25 @@ static bool LoadConfigFiles(void)
|
|||||||
ctype->ValidateObject(object);
|
ctype->ValidateObject(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::copy(items.begin(), items.end(), std::inserter(allItems, allItems.begin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_FOREACH(const ConfigItem::WeakPtr& witem, g_ConfigItems) {
|
||||||
|
ConfigItem::Ptr item = witem.lock();
|
||||||
|
|
||||||
|
/* Ignore this item if it's not active anymore */
|
||||||
|
if (!item || ConfigItem::GetObject(item->GetType(), item->GetName()) != item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Remove the object if it's not in the list of current items */
|
||||||
|
if (allItems.find(item) == allItems.end())
|
||||||
|
item->Unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ConfigItems.clear();
|
||||||
|
std::copy(allItems.begin(), allItems.end(), std::back_inserter(g_ConfigItems));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
Logger::Write(LogCritical, "icinga-app", "Configuration error: " + String(ex.what()));
|
Logger::Write(LogCritical, "icinga-app", "Configuration error: " + String(ex.what()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user