Created
October 8, 2014 09:34
-
-
Save zsol/00d5bb59b12d48406810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp | |
index 8ecfe56..4ec014f 100644 | |
--- a/icinga-app/icinga.cpp | |
+++ b/icinga-app/icinga.cpp | |
@@ -210,8 +210,8 @@ static bool SetDaemonIO(const String& stderrFile) | |
if (fdnull != 0) | |
dup2(fdnull, 0); | |
- if (fdnull != 1) | |
- dup2(fdnull, 1); | |
+ // if (fdnull != 1) | |
+ // dup2(fdnull, 1); | |
if (fdnull > 1) | |
close(fdnull); | |
@@ -514,7 +514,11 @@ int Main(void) | |
ScriptVariable::Set("UseVfork", true, false, true); | |
Application::MakeVariablesConstant(); | |
- | |
+ std::ostringstream oss; | |
+ oss << "/var/log/icinga2/zsol." << static_cast<int>(getpid()) << "log"; | |
+ int logfd = open(oss.str().c_str(), O_CREAT | O_WRONLY | O_APPEND, 0600); | |
+ if (logfd > 0) | |
+ dup2(logfd, 1); | |
Log(LogInformation, "icinga-app", "Icinga application loader (version: " + Application::GetVersion() + ")"); | |
String appType = LoadAppType(Application::GetApplicationType()); | |
@@ -549,6 +553,16 @@ int Main(void) | |
return EXIT_SUCCESS; | |
} | |
+ String errorLog; | |
+ if (g_AppParams.count("errorlog")) { | |
+ errorLog = g_AppParams["errorlog"].as<std::string>(); | |
+ SetDaemonIO(errorLog); | |
+ } | |
+ | |
+ if (g_AppParams.count("daemonize")) { | |
+ Logger::DisableConsoleLog(); | |
+ } | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment