[Zope-Checkins] CVS: Zope - z2.py:1.56.2.1
Chris McDonough
chrism@zope.com
Wed, 23 Jan 2002 12:50:27 -0500
Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv25008
Modified Files:
Tag: chrism_logrotate_branch
z2.py
Log Message:
Integrated Tres' CleanSignalHandling patch as a base to start with.
=== Zope/z2.py 1.56 => 1.56.2.1 ===
pass
+ #
+ # Install signal handlers for SIGHUP and SIGTERM, to permit
+ # clean shutdown/restart from the command line.
+ #
+ if os.name == 'posix': # signal.signal() not reliable on Windos
+ try:
+ import Globals, signal
+ def handler( signum, frame, die=signal.SIGTERM ):
+ for socket in asyncore.socket_map.values():
+ socket.close()
+
+ for db in Globals.opened:
+ try:
+ db.close()
+ finally:
+ pass
+ try:
+ zLOG.LOG( 'z2', zLOG.INFO
+ , "Shutting down (signal %s)" % signum )
+ except:
+ pass
+
+ if signum==die:
+ sys.exit(0)
+ else:
+ sys.exit(1)
+
+ signal.signal( signal.SIGTERM, handler )
+ signal.signal( signal.SIGHUP, handler )
+
+ finally:
+ pass
# if it hasn't failed at this point, create a .pid file.