int Application::m_ArgC;
char **Application::m_ArgV;
double Application::m_StartTime;
-int Application::m_ExitStatus = 0;
/**
* Constructor for the Application class.
void Application::Exit(int rc)
{
+ if (rc)
+ Log(LogCritical, "Application")
+ << "Shutting down after a fatal error; exit code: " << rc;
+ else
+ Log(LogInformation, "Application", "Shutting down...");
+
std::cout.flush();
BOOST_FOREACH(const Logger::Ptr& logger, Logger::GetLoggers()) {
goto mainloop;
}
- if (m_ExitStatus)
- Log(LogInformation, "Application", "Shutting down Icinga after a fatal error.");
- else
- Log(LogInformation, "Application", "Shutting down Icinga...");
-
DynamicObject::StopObjects();
Application::GetInstance()->OnShutdown();
* Signals the application to shut down during the next
* execution of the event loop.
*/
-void Application::RequestShutdown(int rc)
+void Application::RequestShutdown(void)
{
- m_ExitStatus = rc > m_ExitStatus ? rc : m_ExitStatus;
+ Log(LogInformation, "Application", "Received request to shut down.");
+
m_ShuttingDown = true;
}
static void InstallExceptionHandlers(void);
- static void RequestShutdown(int rc = 0);
+ static void RequestShutdown(void);
static void RequestRestart(void);
static void RequestReopenLogs(void);
static bool m_Debugging; /**< Whether debugging is enabled. */
static LogSeverity m_DebuggingSeverity; /**< Whether debugging severity is set. */
static double m_StartTime;
- static int m_ExitStatus;
#ifndef _WIN32
static void SigIntTermHandler(int signum);
Log(LogCritical, "IdoMysqlConnection", "Schema does not provide any valid version! Verify your schema installation.");
- Application::RequestShutdown(EXIT_FAILURE);
- return;
+ Application::Exit(EXIT_FAILURE);
}
DiscardRows(result);
<< "Schema version '" << version << "' does not match the required version '"
<< IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation.";
- Application::RequestShutdown(EXIT_FAILURE);
- return;
+ Application::Exit(EXIT_FAILURE);
}
String instanceName = GetInstanceName();
Log(LogCritical, "IdoPgsqlConnection", "Schema does not provide any valid version! Verify your schema installation.");
- BOOST_THROW_EXCEPTION(std::runtime_error("Schema does not provide any valid version! Verify your schema installation."));
+ Application::Exit(EXIT_FAILURE);
}
String version = row->Get("version");
<< "Schema version '" << version << "' does not match the required version '"
<< IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation.";
- Application::RequestShutdown(EXIT_FAILURE);
- return;
+ Application::Exit(EXIT_FAILURE);
}
String instanceName = GetInstanceName();
if (!AddListener(GetBindHost(), GetBindPort())) {
Log(LogCritical, "ApiListener")
<< "Cannot add listener on host '" << GetBindHost() << "' for port '" << GetBindPort() << "'.";
- Application::RequestShutdown(EXIT_FAILURE);
+ Application::Exit(EXIT_FAILURE);
}
m_Timer = new Timer();