Disable console log after activating all config items

fixes #6316
This commit is contained in:
Gunnar Beutner 2014-06-24 13:04:07 +02:00
parent 6bf47fd221
commit ec903058ef
1 changed files with 10 additions and 8 deletions

View 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,13 +546,6 @@ int Main(void)
return EXIT_FAILURE;
}
}
String errorLog;
if (g_AppParams.count("errorlog"))
errorLog = g_AppParams["errorlog"].as<std::string>();
SetDaemonIO(errorLog);
Logger::DisableConsoleLog();
}
// activate config only after daemonization: it starts threads and that is not compatible with fork()
@ -560,6 +553,15 @@ int Main(void)
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>();
SetDaemonIO(errorLog);
Logger::DisableConsoleLog();
}
#ifndef _WIN32
struct sigaction sa;