mirror of https://github.com/Icinga/icinga2.git
Application::RunEventLoop(): forward restart requests to umbrella process
refs #5230
This commit is contained in:
parent
249408209d
commit
37a3e7e4d5
|
@ -27,6 +27,8 @@
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#else /* _WIN32 */
|
||||||
|
#include <signal.h>
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
#include <systemd/sd-daemon.h>
|
#include <systemd/sd-daemon.h>
|
||||||
|
@ -42,6 +44,11 @@ bool Application::m_ShuttingDown = false;
|
||||||
bool Application::m_RequestRestart = false;
|
bool Application::m_RequestRestart = false;
|
||||||
bool Application::m_RequestReopenLogs = false;
|
bool Application::m_RequestReopenLogs = false;
|
||||||
pid_t Application::m_ReloadProcess = 0;
|
pid_t Application::m_ReloadProcess = 0;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
pid_t Application::m_UmbrellaProcess = 0;
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static bool l_Restarting = false;
|
static bool l_Restarting = false;
|
||||||
static bool l_InExceptionHandler = false;
|
static bool l_InExceptionHandler = false;
|
||||||
int Application::m_ArgC;
|
int Application::m_ArgC;
|
||||||
|
@ -300,11 +307,15 @@ void Application::RunEventLoop()
|
||||||
sd_notify(0, "RELOADING=1");
|
sd_notify(0, "RELOADING=1");
|
||||||
#endif /* HAVE_SYSTEMD */
|
#endif /* HAVE_SYSTEMD */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
// are we already restarting? ignore request if we already are
|
// are we already restarting? ignore request if we already are
|
||||||
if (!l_Restarting) {
|
if (!l_Restarting) {
|
||||||
l_Restarting = true;
|
l_Restarting = true;
|
||||||
m_ReloadProcess = StartReloadProcess();
|
m_ReloadProcess = StartReloadProcess();
|
||||||
}
|
}
|
||||||
|
#else /* _WIN32 */
|
||||||
|
(void)kill(m_UmbrellaProcess, SIGHUP);
|
||||||
|
#endif /* _WIN32 */
|
||||||
} else {
|
} else {
|
||||||
/* Watches for changes to the system time. Adjusts timers if necessary. */
|
/* Watches for changes to the system time. Adjusts timers if necessary. */
|
||||||
Utility::Sleep(2.5);
|
Utility::Sleep(2.5);
|
||||||
|
@ -446,6 +457,13 @@ void Application::RequestReopenLogs()
|
||||||
m_RequestReopenLogs = true;
|
m_RequestReopenLogs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
void Application::SetUmbrellaProcess(pid_t pid)
|
||||||
|
{
|
||||||
|
m_UmbrellaProcess = pid;
|
||||||
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the full path of the executable.
|
* Retrieves the full path of the executable.
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,6 +57,10 @@ public:
|
||||||
static void RequestRestart();
|
static void RequestRestart();
|
||||||
static void RequestReopenLogs();
|
static void RequestReopenLogs();
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
static void SetUmbrellaProcess(pid_t pid);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static bool IsShuttingDown();
|
static bool IsShuttingDown();
|
||||||
static bool IsRestarting();
|
static bool IsRestarting();
|
||||||
|
|
||||||
|
@ -122,6 +126,10 @@ private:
|
||||||
static pid_t m_ReloadProcess; /**< The PID of a subprocess doing a reload, only valid when l_Restarting==true */
|
static pid_t m_ReloadProcess; /**< The PID of a subprocess doing a reload, only valid when l_Restarting==true */
|
||||||
static bool m_RequestReopenLogs; /**< Whether we should re-open log files. */
|
static bool m_RequestReopenLogs; /**< Whether we should re-open log files. */
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
static pid_t m_UmbrellaProcess;
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static int m_ArgC; /**< The number of command-line arguments. */
|
static int m_ArgC; /**< The number of command-line arguments. */
|
||||||
static char **m_ArgV; /**< Command-line arguments. */
|
static char **m_ArgV; /**< Command-line arguments. */
|
||||||
FILE *m_PidFile; /**< The PID file */
|
FILE *m_PidFile; /**< The PID file */
|
||||||
|
|
|
@ -477,6 +477,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
||||||
return RunWorker(configs);
|
return RunWorker(configs);
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
l_UmbrellaPid = getpid();
|
l_UmbrellaPid = getpid();
|
||||||
|
Application::SetUmbrellaProcess(l_UmbrellaPid);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
Loading…
Reference in New Issue