]> granicus.if.org Git - icinga2/commitdiff
Make PID path configurable.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 13 Jul 2012 06:30:20 +0000 (08:30 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 13 Jul 2012 06:30:20 +0000 (08:30 +0200)
doc/icinga2-config.odt
icinga/icingaapplication.cpp
icinga/icingaapplication.h

index b79201e6348127b482b07130ed1e3a927194a227..a9b8ee5844316836a7e7174c62eaec876b6f2857 100644 (file)
Binary files a/doc/icinga2-config.odt and b/doc/icinga2-config.odt differ
index aa50ea7ca67736b95612542fe727a2c9d284a139..85d8471766e154ec84534ada9163437bf65aeec0 100644 (file)
 
 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;
index f2e920fe3c8ce9729276112b4abd64aaf96095c1..b8d5f90622363bc1ed7d039c1dcdd8ef96f53105 100644 (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;