mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-07 13:54:38 +02:00
parent
368ebf4fbf
commit
06b504f291
@ -80,7 +80,9 @@ void Application::Stop(bool runtimeRemoved)
|
|||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
ClosePidFile(true);
|
ClosePidFile(true);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
ObjectImpl<Application>::Stop(runtimeRemoved);
|
ObjectImpl<Application>::Stop(runtimeRemoved);
|
||||||
}
|
}
|
||||||
@ -964,6 +966,7 @@ int Application::Run()
|
|||||||
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
|
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
try {
|
try {
|
||||||
UpdatePidFile(Configuration::PidPath);
|
UpdatePidFile(Configuration::PidPath);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
@ -971,6 +974,7 @@ int Application::Run()
|
|||||||
<< "Cannot update PID file '" << Configuration::PidPath << "'. Aborting.";
|
<< "Cannot update PID file '" << Configuration::PidPath << "'. Aborting.";
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
SetMainTime(Utility::GetTime());
|
SetMainTime(Utility::GetTime());
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ private:
|
|||||||
|
|
||||||
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 = nullptr; /**< The PID file */
|
||||||
static bool m_Debugging; /**< Whether debugging is enabled. */
|
static bool m_Debugging; /**< Whether debugging is enabled. */
|
||||||
static LogSeverity m_DebuggingSeverity; /**< Whether debugging severity is set. */
|
static LogSeverity m_DebuggingSeverity; /**< Whether debugging severity is set. */
|
||||||
static double m_StartTime;
|
static double m_StartTime;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
#include "config/configcompilercontext.hpp"
|
#include "config/configcompilercontext.hpp"
|
||||||
#include "config/configitembuilder.hpp"
|
#include "config/configitembuilder.hpp"
|
||||||
|
#include "base/defer.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/application.hpp"
|
#include "base/application.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
@ -412,6 +413,15 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs)
|
|||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PidFileManagementApp : public Application
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline int Main() override
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,6 +476,22 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
|||||||
Daemonize();
|
Daemonize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
PidFileManagementApp app;
|
||||||
|
|
||||||
|
try {
|
||||||
|
app.UpdatePidFile(Configuration::PidPath);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
Log(LogCritical, "Application")
|
||||||
|
<< "Cannot update PID file '" << Configuration::PidPath << "'. Aborting.";
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Defer closePidFile ([&app]() {
|
||||||
|
app.ClosePidFile(true);
|
||||||
|
});
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
if (vm.count("daemonize") || vm.count("close-stdio")) {
|
if (vm.count("daemonize") || vm.count("close-stdio")) {
|
||||||
// After disabling the console log, any further errors will go to the configured log only.
|
// After disabling the console log, any further errors will go to the configured log only.
|
||||||
// Let's try to make this clear and say good bye.
|
// Let's try to make this clear and say good bye.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user