[Zope-Checkins] CVS: Zope/lib/python/Signals - Signals.py:1.1.2.2
Chris McDonough
chrism@zope.com
Mon, 25 Nov 2002 18:20:14 -0500
Update of /cvs-repository/Zope/lib/python/Signals
In directory cvs.zope.org:/tmp/cvs-serv32566
Modified Files:
Tag: Zope-2_6-branch
Signals.py
Log Message:
Modified.
=== Zope/lib/python/Signals/Signals.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/Signals/Signals.py:1.1.2.1 Mon Nov 25 18:17:03 2002
+++ Zope/lib/python/Signals/Signals.py Mon Nov 25 18:20:14 2002
@@ -17,29 +17,24 @@
"""
__version__='$Revision$'[11:-2]
-from SignalHandler import SignalHandler
+from zdaemon.SignalHandler import SignalHandler
import zLOG
import sys
-import Lifetime
-
-def shutdownFastHandler():
- """Shutdown cleanly on SIGTERM. This is registered first,
- so it should be called after all other handlers."""
- zLOG.LOG('Z2', zLOG.INFO , "Shutting down fast")
- Lifetime.shutdown(0,fast=1)
-
+import ZLogger
def shutdownHandler():
- """Shutdown cleanly on SIGINT. This is registered first,
+ """Shutdown cleanly on SIGTERM, SIGINT. This is registered first,
so it should be called after all other handlers."""
+ closeall()
zLOG.LOG('Z2', zLOG.INFO , "Shutting down")
sys.exit(0)
def restartHandler():
"""Restart cleanly on SIGHUP. This is registered first, so it
should be called after all other SIGHUP handlers."""
+ closeall()
zLOG.LOG('Z2', zLOG.INFO , "Restarting")
- Lifetime.shutdown(1)
+ sys.exit(1)
def logfileReopenHandler():
"""Reopen log files on SIGUSR2. This is registered first, so it
@@ -53,7 +48,11 @@
if reopen is not None:
reopen()
zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log")
- zLOG.initialize()
+ if hasattr(zLOG, '_set_stupid_dest'):
+ zLOG._set_stupid_dest(None)
+ else:
+ zLOG._stupid_dest = None
+ ZLogger.stupidFileLogger._stupid_dest = None
zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log")
zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
@@ -72,9 +71,19 @@
'Call to pack failed!', error=sys.exc_info())
+def closeall():
+ """Helper method to close database connections. This also used
+ to close network connections, but that hosed ZEO clients in some
+ instances, so we don't do that anymore"""
+ import Globals
+
+ zLOG.LOG('Z2', zLOG.INFO, "Closing all open ZODB databases")
+ for db in Globals.opened:
+ db.close()
+
def registerZopeSignals():
import signal
- SignalHandler.registerHandler(signal.SIGTERM, shutdownFastHandler)
+ SignalHandler.registerHandler(signal.SIGTERM, shutdownHandler)
SignalHandler.registerHandler(signal.SIGINT, shutdownHandler)
SignalHandler.registerHandler(signal.SIGHUP, restartHandler)
SignalHandler.registerHandler(signal.SIGUSR2, logfileReopenHandler)