mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8429 from Icinga/bugfix/last-reload-attempt-failed-8428
Share "Last reload attempt failed" time across Icinga process tree on *nix
This commit is contained in:
commit
b0899d9ab4
|
@ -62,7 +62,12 @@ int Application::m_ArgC;
|
||||||
char **Application::m_ArgV;
|
char **Application::m_ArgV;
|
||||||
double Application::m_StartTime;
|
double Application::m_StartTime;
|
||||||
bool Application::m_ScriptDebuggerEnabled = false;
|
bool Application::m_ScriptDebuggerEnabled = false;
|
||||||
double Application::m_LastReloadFailed;
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
double Application::m_LastReloadFailed = 0;
|
||||||
|
#else /* _WIN32 */
|
||||||
|
SharedMemory<Application::AtomicTs> Application::m_LastReloadFailed (0);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static LPTOP_LEVEL_EXCEPTION_FILTER l_DefaultUnhandledExceptionFilter = nullptr;
|
static LPTOP_LEVEL_EXCEPTION_FILTER l_DefaultUnhandledExceptionFilter = nullptr;
|
||||||
|
@ -1208,12 +1213,20 @@ void Application::SetScriptDebuggerEnabled(bool enabled)
|
||||||
|
|
||||||
double Application::GetLastReloadFailed()
|
double Application::GetLastReloadFailed()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
return m_LastReloadFailed;
|
return m_LastReloadFailed;
|
||||||
|
#else /* _WIN32 */
|
||||||
|
return m_LastReloadFailed.Get().load();
|
||||||
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::SetLastReloadFailed(double ts)
|
void Application::SetLastReloadFailed(double ts)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
m_LastReloadFailed = ts;
|
m_LastReloadFailed = ts;
|
||||||
|
#else /* _WIN32 */
|
||||||
|
m_LastReloadFailed.Get().store(ts);
|
||||||
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::ValidateName(const Lazy<String>& lvalue, const ValidationUtils& utils)
|
void Application::ValidateName(const Lazy<String>& lvalue, const ValidationUtils& utils)
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#define APPLICATION_H
|
#define APPLICATION_H
|
||||||
|
|
||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
|
#include "base/atomic.hpp"
|
||||||
#include "base/application-ti.hpp"
|
#include "base/application-ti.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/configuration.hpp"
|
#include "base/configuration.hpp"
|
||||||
|
#include "base/shared-memory.hpp"
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -137,7 +139,13 @@ private:
|
||||||
static double m_StartTime;
|
static double m_StartTime;
|
||||||
static double m_MainTime;
|
static double m_MainTime;
|
||||||
static bool m_ScriptDebuggerEnabled;
|
static bool m_ScriptDebuggerEnabled;
|
||||||
|
#ifdef _WIN32
|
||||||
static double m_LastReloadFailed;
|
static double m_LastReloadFailed;
|
||||||
|
#else /* _WIN32 */
|
||||||
|
typedef Atomic<double> AtomicTs;
|
||||||
|
static_assert(AtomicTs::is_always_lock_free);
|
||||||
|
static SharedMemory<AtomicTs> m_LastReloadFailed;
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static BOOL WINAPI CtrlHandler(DWORD type);
|
static BOOL WINAPI CtrlHandler(DWORD type);
|
||||||
|
|
|
@ -813,6 +813,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
||||||
break;
|
break;
|
||||||
case -2:
|
case -2:
|
||||||
Log(LogCritical, "Application", "Found error in config: reloading aborted");
|
Log(LogCritical, "Application", "Found error in config: reloading aborted");
|
||||||
|
Application::SetLastReloadFailed(Utility::GetTime());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogInformation, "Application")
|
Log(LogInformation, "Application")
|
||||||
|
@ -820,6 +821,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
||||||
|
|
||||||
NotifyStatus("Shutting down old instance...");
|
NotifyStatus("Shutting down old instance...");
|
||||||
|
|
||||||
|
Application::SetLastReloadFailed(0);
|
||||||
(void)kill(currentWorker, SIGTERM);
|
(void)kill(currentWorker, SIGTERM);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue