Changeset 2110

Show
Ignore:
Timestamp:
13/03/2008 21:48:05 (10 months ago)
Author:
chris
Message:

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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/server/Daemon.cpp

    r2103 r2110  
    5353          mSingleProcess(false), 
    5454          mRunInForeground(false), 
     55        #ifdef WIN32 
     56          mKeepConsoleOpenAfterFork(true), 
     57        #else 
    5558          mKeepConsoleOpenAfterFork(false), 
     59        #endif 
    5660          mHaveConfigFile(false), 
    5761          mAppName(DaemonName()) 
     
    104108{ 
    105109        return "c:" 
    106         #ifndef WIN32 
     110        #ifdef WIN32 
     111                "K" 
     112        #else // !WIN32 
    107113                "DFkP" 
    108114        #endif 
     
    121127        "             argument is the configuration file, or else the default \n" 
    122128        "             [" << GetConfigFileName() << "]\n" 
    123 #ifndef WIN32 
     129#ifdef WIN32 
     130        "  -K         Stop writing log messages to console while daemon is running\n" 
     131#else // !WIN32 
    124132        "  -D         Debugging mode, do not fork, one process only, one client only\n" 
    125133        "  -F         Do not fork into background, but fork to serve multiple clients\n" 
     
    157165                break; 
    158166 
    159 #ifndef WIN32 
     167#ifdef WIN32 
     168                case 'K': 
     169                { 
     170                        mKeepConsoleOpenAfterFork = false; 
     171                } 
     172                break; 
     173#else // !WIN32 
    160174                case 'D': 
    161175                { 
     
    491505#endif // !WIN32 
    492506 
    493                 // Log the start message 
    494                 BOX_NOTICE("Starting daemon, version " << BOX_VERSION 
    495                         << ", config: " << mConfigFileName); 
    496  
    497507                // Write PID to file 
    498508                char pid[32]; 
     
    519529                #endif // BOX_MEMORY_LEAK_TESTING 
    520530         
    521                 if(asDaemon && !mKeepConsoleOpenAfterFork) 
     531                if( 
     532                        #ifndef WIN32 
     533                                asDaemon &&  
     534                        #endif 
     535                        !mKeepConsoleOpenAfterFork) 
    522536                { 
    523537#ifndef WIN32 
     
    546560                        // -- this has in the past sent text to something which isn't expecting it. 
    547561                        TRACE_TO_STDOUT(false); 
     562#endif // ! WIN32 
    548563                        Logging::ToConsole(false); 
    549 #endif // ! WIN32 
    550564                }                
     565 
     566                // Log the start message 
     567                BOX_NOTICE("Starting daemon, version: " << BOX_VERSION); 
     568                BOX_NOTICE("Using configuration file: " << mConfigFileName); 
    551569        } 
    552570        catch(BoxException &e)