[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Improve error handling and server startup reporting:



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv10608/lib/mixminion/server

Modified Files:
	Modules.py ServerMain.py 
Log Message:
Improve error handling and server startup reporting:

ClientMain:
        - Change many messages to UIError exceptions

ModuleManager:
        - Downgrade 'Disabling module' from info to debug.

Common, ServerMain:
        - Change daemonization and log configuration to avoid shutting down
          console messages until the first moment we enter the main loop.
          This should make it easier to notice when the server hits an
          exception on startup.



Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Modules.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- Modules.py	13 Feb 2003 06:30:23 -0000	1.31
+++ Modules.py	13 Feb 2003 07:03:50 -0000	1.32
@@ -372,7 +372,7 @@
 
     def disableModule(self, module):
         """Unmaps all the types for a module object."""
-        LOG.info("Disabling module %s", module.getName())
+        LOG.debug("Disabling module %s", module.getName())
         for t in module.getExitTypes():
             if (self.typeToModule.has_key(t) and
                 self.typeToModule[t].getName() == module.getName()):

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- ServerMain.py	13 Feb 2003 06:30:23 -0000	1.38
+++ ServerMain.py	13 Feb 2003 07:03:50 -0000	1.39
@@ -501,6 +501,14 @@
         LOG.debug("First mix at %s", formatTime(nextMix,1))
         scheduledEvents.sort()
 
+        LOG.info("Entering main loop: Mixminion %s", mixminion.__version__)
+
+        # This is the last possible moment to shut down the console log, so
+        # we have to do it now.
+        mixminion.Common.LOG.configure(self.config, keepStderr=0)
+        if self.config['Server'].get("Daemon",1):
+            closeUnusedFDs()        
+
         # FFFF Support for automatic key rotation.
         while 1:
             nextEventTime = scheduledEvents[0][0]
@@ -625,7 +633,9 @@
     # Set umask to 000 so that we drop any (possibly nutty) umasks that
     # our users had before.
     os.umask(0000)
-    # Close all unused fds.
+
+def closeUnusedFDs():
+    """Close stdin, stdout, and stderr."""
     # (We could try to do this via sys.stdin.close() etc., but then we
     #  would miss the magic copies in sys.__stdin__, sys.__stdout__, etc.
     #  Using os.close instead just nukes the FD for us.)
@@ -689,17 +699,18 @@
 def runServer(cmd, args):
     config = configFromServerArgs(cmd, args)
     try:
-        mixminion.Common.LOG.configure(config)
+        #DOCDOC
+        mixminion.Common.LOG.configure(config, keepStderr=1)
         LOG.debug("Configuring server")
     except:
         info = sys.exc_info()
         LOG.fatal_exc(info,"Exception while configuring server")
         LOG.fatal("Shutting down because of exception: %s", info[0])
-        #XXXX if sys.stderr is still real, send a message there as well.
         sys.exit(1)
 
-    if config['Server'].get("Daemon",1):
-        print "Starting server in the background"
+    daemonMode = config['Server'].get("Daemon",1)
+    if daemonMode:
+        LOG.info("Starting server in the background")
         try:
             daemonize()
         except:
@@ -720,11 +731,12 @@
         info = sys.exc_info()
         LOG.fatal_exc(info,"Exception while configuring server")
         LOG.fatal("Shutting down because of exception: %s", info[0])
-        #XXXX if sys.stderr is still real, send a message there as well.
         sys.exit(1)            
             
     LOG.info("Starting server: Mixminion %s", mixminion.__version__)
     try:
+        # We keep the console log open as long as possible so we can catch
+        # more errors.
         server.run()
     except KeyboardInterrupt:
         pass
@@ -732,7 +744,7 @@
         info = sys.exc_info()
         LOG.fatal_exc(info,"Exception while running server")
         LOG.fatal("Shutting down because of exception: %s", info[0])
-        #XXXX if sys.stderr is still real, send a message there as well.
+
     LOG.info("Server shutting down")
     server.close()
     LOG.info("Server is shut down")