[Zope-Checkins] CVS: Zope/lib/python/App - ApplicationManager.py:1.81.10.1

Toby Dickenson tdickenson@geminidataloggers.com
Thu, 10 Oct 2002 13:27:54 -0400


Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv27621/lib/python/App

Modified Files:
      Tag: toby-clean-shutdown-branch
	ApplicationManager.py 
Log Message:
draft implementation of the clean shutdown proposal. ZMI and signal-based shutdown methods now set a global variable. This global variable causes the main medusa loop to return. We then gradually shut down sockets, in the right order. If any clients are slowly downloading a file then they can cause the shutdown to be delayed by up to 30 seconds, to allow them time to complete. This is true unless the shutdown was triggered by SIGTERM - we need to shutdown fast because the whole machine might be going down, and we can expect a SIGKILL within a few seconds.

=== Zope/lib/python/App/ApplicationManager.py 1.81 => 1.81.10.1 ===
--- Zope/lib/python/App/ApplicationManager.py:1.81	Wed Aug 14 17:31:40 2002
+++ Zope/lib/python/App/ApplicationManager.py	Thu Oct 10 13:27:53 2002
@@ -28,6 +28,7 @@
 from cStringIO import StringIO
 from AccessControl import getSecurityManager
 import zLOG
+import Lifetime
 
 try: import thread
 except: get_ident=lambda: 0
@@ -326,12 +327,12 @@
             zLOG.LOG("ApplicationManager", zLOG.INFO,
                      "Restart requested by %s" % user)
             for db in Globals.opened: db.close()
-            raise SystemExit, """<html>
+            Lifetime.shutdown(1)
+            return """<html>
             <head><meta HTTP-EQUIV=REFRESH CONTENT="5; URL=%s/manage_main">
             </head>
             <body>Zope is restarting</body></html>
             """ % URL1
-            sys.exit(1)
 
     def manage_shutdown(self):
         """Shut down the application"""
@@ -341,8 +342,13 @@
             user = 'unknown user'
         zLOG.LOG("ApplicationManager", zLOG.INFO,
                  "Shutdown requested by %s" % user)
-        for db in Globals.opened: db.close()
-        sys.exit(0)
+        #for db in Globals.opened: db.close()
+        Lifetime.shutdown(0)
+        return """<html>
+        <head>
+        </head>
+        <body>Zope is shutting down</body></html>
+        """
 
     def manage_pack(self, days=0, REQUEST=None):
         """Pack the database"""