Make PID path configurable.

This commit is contained in:
Gunnar Beutner 2012-07-13 08:30:20 +02:00
parent 9104bdd8da
commit e5ae9dd94e
3 changed files with 19 additions and 5 deletions

Binary file not shown.

View File

@ -28,7 +28,11 @@
using namespace icinga;
const string IcingaApplication::PidFilename = "icinga.pid";
const string IcingaApplication::DefaultPidPath = "icinga.pid";
IcingaApplication::IcingaApplication(void)
: m_PidPath(DefaultPidPath)
{ }
/**
* The entry point for the Icinga application.
@ -49,8 +53,6 @@ int IcingaApplication::Main(const vector<string>& args)
time(&m_StartTime);
UpdatePidFile(PidFilename);
if (args.size() < 2) {
stringstream msgbuf;
msgbuf << "Syntax: " << args[0] << " [-S] [-L logfile] [-d] [--] <config-file>";
@ -155,6 +157,9 @@ int IcingaApplication::Main(const vector<string>& args)
icingaConfig->GetProperty("ca", &m_CAFile);
icingaConfig->GetProperty("node", &m_Node);
icingaConfig->GetProperty("service", &m_Service);
icingaConfig->GetProperty("pidpath", &m_PidPath);
UpdatePidFile(GetPidPath());
if (!GetCertificateFile().empty() && !GetCAFile().empty()) {
/* set up SSL context */
@ -176,7 +181,7 @@ int IcingaApplication::Main(const vector<string>& args)
Logger::Write(LogInformation, "icinga", "Daemonizing.");
ClosePidFile();
Utility::Daemonize();
UpdatePidFile(PidFilename);
UpdatePidFile(GetPidPath());
Logger::UnregisterLogger(consoleLogger);
}
@ -234,6 +239,11 @@ string IcingaApplication::GetService(void) const
return m_Service;
}
string IcingaApplication::GetPidPath(void) const
{
return m_PidPath;
}
time_t IcingaApplication::GetStartTime(void) const
{
return m_StartTime;

View File

@ -34,6 +34,8 @@ public:
typedef shared_ptr<IcingaApplication> Ptr;
typedef weak_ptr<IcingaApplication> WeakPtr;
IcingaApplication(void);
int Main(const vector<string>& args);
static IcingaApplication::Ptr GetInstance(void);
@ -42,16 +44,18 @@ public:
string GetCAFile(void) const;
string GetNode(void) const;
string GetService(void) const;
string GetPidPath(void) const;
time_t GetStartTime(void) const;
static const string PidFilename;
static const string DefaultPidPath;
private:
string m_CertificateFile;
string m_CAFile;
string m_Node;
string m_Service;
string m_PidPath;
time_t m_StartTime;