From e56e493a006e1feaa200190c61e4951ffb002624 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 26 Jul 2012 11:41:36 +0200 Subject: [PATCH] Save program state when shutting down. --- icinga/icingaapplication.cpp | 9 ++++++--- icinga/icingaapplication.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 047a982e1..6c1a28a36 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -47,7 +47,7 @@ int IcingaApplication::Main(const vector& args) m_RetentionTimer = boost::make_shared(); 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& 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) diff --git a/icinga/icingaapplication.h b/icinga/icingaapplication.h index d8f5a9540..780a0674a 100644 --- a/icinga/icingaapplication.h +++ b/icinga/icingaapplication.h @@ -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);