]> granicus.if.org Git - icinga2/commitdiff
Save program state when shutting down.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 26 Jul 2012 09:41:36 +0000 (11:41 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 26 Jul 2012 09:41:36 +0000 (11:41 +0200)
icinga/icingaapplication.cpp
icinga/icingaapplication.h

index 047a982e1c7dfeb08de3ff76f20f0c7bf48ee31b..6c1a28a36eb13853c56fe58edab6a8d2c69f64d2 100644 (file)
@@ -47,7 +47,7 @@ int IcingaApplication::Main(const vector<string>& args)
 
        m_RetentionTimer = boost::make_shared<Timer>();
        m_RetentionTimer->SetInterval(60);
-       m_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::RetentionTimerHandler, this));
+       m_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this));
        m_RetentionTimer->Start();
 
        /* register handler for 'log' config objects */
@@ -225,13 +225,16 @@ int IcingaApplication::Main(const vector<string>& args)
 
        RunEventLoop();
 
+       DumpProgramState();
+
        Logger::Write(LogInformation, "icinga", "Icinga shutting down.");
 
        return EXIT_SUCCESS;
 }
 
-void IcingaApplication::RetentionTimerHandler(void) {
-       ConfigObject::DumpObjects("retention.dat");
+void IcingaApplication::DumpProgramState(void) {
+       ConfigObject::DumpObjects("retention.dat.tmp");
+       rename("retention.dat.tmp", "retention.dat");
 }
 
 void IcingaApplication::NewComponentHandler(const ConfigObject::Ptr& object)
index d8f5a9540fd65b7d676124e8d1c8e0d3aba83942..780a0674a384acc24df7de3e0cf00633091f13e7 100644 (file)
@@ -63,7 +63,7 @@ private:
 
        Timer::Ptr m_RetentionTimer;
 
-       void RetentionTimerHandler(void);
+       void DumpProgramState(void);
 
        void NewComponentHandler(const ConfigObject::Ptr& object);
        void DeletedComponentHandler(const ConfigObject::Ptr& object);