mirror of https://github.com/Icinga/icinga2.git
parent
2dfd73ab5f
commit
d6bc5a1a18
|
@ -680,29 +680,6 @@ void Application::AttachDebugger(const String& filename, bool interactive)
|
|||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
* Signal handler for SIGINT and SIGTERM. Prepares the application for cleanly
|
||||
* shutting down during the next execution of the event loop.
|
||||
*
|
||||
* @param - The signal number.
|
||||
*/
|
||||
void Application::SigIntTermHandler(int signum)
|
||||
{
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigaction(signum, &sa, nullptr);
|
||||
|
||||
Application::Ptr instance = Application::GetInstance();
|
||||
|
||||
if (!instance)
|
||||
return;
|
||||
|
||||
instance->RequestShutdown();
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/**
|
||||
* Signal handler for SIGUSR1. This signal causes Icinga to re-open
|
||||
* its log files and is mainly for use by logrotate.
|
||||
|
@ -717,42 +694,6 @@ void Application::SigUsr1Handler(int)
|
|||
RequestReopenLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal handler for SIGUSR2. Hands over PID to child and commits suicide
|
||||
*
|
||||
* @param - The signal number.
|
||||
*/
|
||||
void Application::SigUsr2Handler(int)
|
||||
{
|
||||
Log(LogInformation, "Application", "Reload requested, letting new process take over.");
|
||||
#ifdef HAVE_SYSTEMD
|
||||
sd_notifyf(0, "MAINPID=%lu", (unsigned long) m_ReloadProcess);
|
||||
#endif /* HAVE_SYSTEMD */
|
||||
|
||||
/* Write the PID of the new process to the pidfile before this
|
||||
* process exits to keep systemd happy.
|
||||
*/
|
||||
Application::Ptr instance = GetInstance();
|
||||
try {
|
||||
instance->UpdatePidFile(Configuration::PidPath, m_ReloadProcess);
|
||||
} catch (const std::exception&) {
|
||||
/* abort restart */
|
||||
Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
|
||||
return;
|
||||
}
|
||||
|
||||
instance->ClosePidFile(false);
|
||||
|
||||
/* Ensure to dump the program state on reload. */
|
||||
ConfigObject::StopObjects();
|
||||
instance->OnShutdown();
|
||||
|
||||
Log(LogInformation, "Application")
|
||||
<< "Reload done, parent process shutting down. Child process with PID '" << m_ReloadProcess << "' is taking over.";
|
||||
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal handler for SIGABRT. Helps with debugging ASSERT()s.
|
||||
*
|
||||
|
@ -999,15 +940,8 @@ int Application::Run()
|
|||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = &Application::SigIntTermHandler;
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
sigaction(SIGTERM, &sa, nullptr);
|
||||
|
||||
sa.sa_handler = &Application::SigUsr1Handler;
|
||||
sigaction(SIGUSR1, &sa, nullptr);
|
||||
|
||||
sa.sa_handler = &Application::SigUsr2Handler;
|
||||
sigaction(SIGUSR2, &sa, nullptr);
|
||||
#else /* _WIN32 */
|
||||
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
@ -132,9 +132,7 @@ private:
|
|||
static bool m_ScriptDebuggerEnabled;
|
||||
static double m_LastReloadFailed;
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigIntTermHandler(int signum);
|
||||
#else /* _WIN32 */
|
||||
#ifdef _WIN32
|
||||
static BOOL WINAPI CtrlHandler(DWORD type);
|
||||
static LONG WINAPI SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi);
|
||||
#endif /* _WIN32 */
|
||||
|
@ -143,7 +141,6 @@ private:
|
|||
|
||||
static void SigAbrtHandler(int signum);
|
||||
static void SigUsr1Handler(int signum);
|
||||
static void SigUsr2Handler(int signum);
|
||||
static void ExceptionHandler();
|
||||
|
||||
static String GetCrashReportFilename();
|
||||
|
|
|
@ -27,13 +27,6 @@ static po::variables_map g_AppParams;
|
|||
|
||||
REGISTER_CLICOMMAND("daemon", DaemonCommand);
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigHupHandler(int)
|
||||
{
|
||||
Application::RequestRestart();
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Daemonize(). On error, this function logs by itself and exits (i.e. does not return).
|
||||
*
|
||||
|
@ -299,13 +292,6 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
|||
<< "Cannot clean ignored downtimes/comments: " << ex.what();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = &SigHupHandler;
|
||||
sigaction(SIGHUP, &sa, nullptr);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
ApiListener::UpdateObjectAuthority();
|
||||
|
||||
return Application::GetInstance()->Run();
|
||||
|
|
Loading…
Reference in New Issue