SERVER-2833 -- shut down cleanly on OS or Service Controller shutdown event

Added code to log shutdown events from the Windows Service Controller
and to respond correctly to those events.  Shutdown from the console
on logoff or shutdown callbacks (stop ignoring them).
This commit is contained in:
Tad Marshall
2011-12-01 20:42:13 -05:00
parent c6228e1970
commit c8e45cce25
4 changed files with 51 additions and 19 deletions

View File

@@ -927,6 +927,15 @@ namespace mongo {
catch (...) { }
#endif
#ifdef _WIN32
// Windows Service Controller wants to be told when we are down,
// so don't call ::exit() yet, or say "really exiting now"
//
if ( rc == EXIT_WINDOWS_SERVICE_STOP ) {
if ( c ) c->shutdown();
return;
}
#endif
tryToOutputFatal( "dbexit: really exiting now" );
if ( c ) c->shutdown();
::exit(rc);