[Zope-Checkins] CVS: Zope/ZServer - DebugLogger.py:1.7
Chris McDonough
chrism@zope.com
Tue, 11 Jun 2002 18:03:17 -0400
Update of /cvs-repository/Zope/ZServer
In directory cvs.zope.org:/tmp/cvs-serv24893
Modified Files:
DebugLogger.py
Log Message:
These patches provide clean signal handling and logfile rotation to Zope.
All Zope process will respond to signals in the specified manner:
SIGHUP - close open database connections and sockets, then restart the
process
SIGTERM - close open database connections and sockets, then shut down.
SIGINT - same as SIGTERM
SIGUSR2 - rotate all Zope log files (z2.log, event log, detailed log)
The common idiom for doing automated logfile rotation will become:
kill -USR2 `cat /path/to/var/z2.pid`
The common idiom for doing "prophylactic" restarts will become:
kill -HUP `cat /path/to/var/z2.pid`
When a process is interrupted via ctrl-C or via a TERM signal (INT, TERM),
all open database connections and sockets will be closed before
the process dies. This will speed up restart time for sites that
use a FileStorage as its index will be written to the filesystem before
shutdown.
Unspecified signals kill the process without doing cleanup.
=== Zope/ZServer/DebugLogger.py 1.6 => 1.7 ===
def __init__(self, filename):
+ self.filename = filename
self.file=open(filename, 'a+b')
l=thread.allocate_lock()
self._acquire=l.acquire
self._release=l.release
self.log('U', '000000000', 'System startup')
+ def reopen(self):
+ self.file.close()
+ self.file=open(self.filename, 'a+b')
+ self.log('U', '000000000', 'Logfile reopened')
+
def log(self, code, request_id, data=''):
self._acquire()
try: