]> granicus.if.org Git - icinga2/commitdiff
Disable console log after activating all config items
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 24 Jun 2014 11:04:07 +0000 (13:04 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 24 Jun 2014 11:04:07 +0000 (13:04 +0200)
fixes #6316

icinga-app/icinga.cpp

index ce12db189cdb5404377eb9b7fab421bdd2172f22..773917199bde5cfca1219b041d277fa9da06cf70 100644 (file)
@@ -185,7 +185,7 @@ static bool Daemonize(void)
                } while (readpid != pid && ret == 0);
 
                if (ret == pid) {
-                       Log(LogCritical, "icinga-app", "The daemon could not be started. See logfile for details.");
+                       Log(LogCritical, "icinga-app", "The daemon could not be started. See log output for details.");
                        exit(EXIT_FAILURE);
                } else if (ret == -1) {
                        std::ostringstream msgbuf;
@@ -546,7 +546,15 @@ int Main(void)
                                return EXIT_FAILURE;
                        }
                }
+       }
+
+       // activate config only after daemonization: it starts threads and that is not compatible with fork()
+       if (!ConfigItem::ActivateItems()) {
+               Log(LogCritical, "icinga-app", "Error activating configuration.");
+               return EXIT_FAILURE;
+       }
 
+       if (g_AppParams.count("daemonize")) {
                String errorLog;
                if (g_AppParams.count("errorlog"))
                        errorLog = g_AppParams["errorlog"].as<std::string>();
@@ -554,12 +562,6 @@ int Main(void)
                SetDaemonIO(errorLog);
                Logger::DisableConsoleLog();
        }
-
-       // activate config only after daemonization: it starts threads and that is not compatible with fork()
-       if (!ConfigItem::ActivateItems()) {
-               Log(LogCritical, "icinga-app", "Error activating configuration.");
-               return EXIT_FAILURE;
-       }
        
 #ifndef _WIN32
        struct sigaction sa;