diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-03-13 21:48:05 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-03-13 21:48:05 +0000 |
commit | e0f4b63be5993ce19446e8bc75f92a4dd5cc4f0b (patch) | |
tree | 53cc229f38395b012536f896570b55b3ed485fe8 /lib/server | |
parent | d51e5a7ccf93d8a917edc5eb29fea641353ffc94 (diff) |
Add the -K option to Daemons on Windows to keep them quiet even though
they don't fork by themselves. This is because the tests are able to run
them in the background, and if they keep the console open then they will
continue to spew to it. This option is normally only useful when running
the daemon in a test.
Diffstat (limited to 'lib/server')
-rw-r--r-- | lib/server/Daemon.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index bb9785d8..95f5c338 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -52,7 +52,11 @@ Daemon::Daemon() mTerminateWanted(false), mSingleProcess(false), mRunInForeground(false), + #ifdef WIN32 + mKeepConsoleOpenAfterFork(true), + #else mKeepConsoleOpenAfterFork(false), + #endif mHaveConfigFile(false), mAppName(DaemonName()) { @@ -103,7 +107,9 @@ Daemon::~Daemon() std::string Daemon::GetOptionString() { return "c:" - #ifndef WIN32 + #ifdef WIN32 + "K" + #else // !WIN32 "DFkP" #endif "hqvVt:TU"; @@ -120,7 +126,9 @@ void Daemon::Usage() " -c <file> Use the specified configuration file. If -c is omitted, the last\n" " argument is the configuration file, or else the default \n" " [" << GetConfigFileName() << "]\n" -#ifndef WIN32 +#ifdef WIN32 + " -K Stop writing log messages to console while daemon is running\n" +#else // !WIN32 " -D Debugging mode, do not fork, one process only, one client only\n" " -F Do not fork into background, but fork to serve multiple clients\n" " -k Keep console open after fork, keep writing log messages to it\n" @@ -156,7 +164,13 @@ int Daemon::ProcessOption(signed int option) } break; -#ifndef WIN32 +#ifdef WIN32 + case 'K': + { + mKeepConsoleOpenAfterFork = false; + } + break; +#else // !WIN32 case 'D': { mSingleProcess = true; @@ -490,10 +504,6 @@ int Daemon::Main(const std::string &rConfigFileName) } #endif // !WIN32 - // Log the start message - BOX_NOTICE("Starting daemon, version " << BOX_VERSION - << ", config: " << mConfigFileName); - // Write PID to file char pid[32]; @@ -518,7 +528,11 @@ int Daemon::Main(const std::string &rConfigFileName) } #endif // BOX_MEMORY_LEAK_TESTING - if(asDaemon && !mKeepConsoleOpenAfterFork) + if( + #ifndef WIN32 + asDaemon && + #endif + !mKeepConsoleOpenAfterFork) { #ifndef WIN32 // Close standard streams @@ -545,9 +559,13 @@ int Daemon::Main(const std::string &rConfigFileName) // And definitely don't try and send anything to those file descriptors // -- this has in the past sent text to something which isn't expecting it. TRACE_TO_STDOUT(false); - Logging::ToConsole(false); #endif // ! WIN32 + Logging::ToConsole(false); } + + // Log the start message + BOX_NOTICE("Starting daemon, version: " << BOX_VERSION); + BOX_NOTICE("Using configuration file: " << mConfigFileName); } catch(BoxException &e) { |