- Zope dies under mysterious circumstances
Thus far, I haven't been able to make Zope die, but it does die. I am actually running it now using the supervise program which comes with qmail's daemontools package (I get log rotation this way, as well). I know it died because I checked the contol panel. Going back into the log at about the time it happened, there are no obvious error messages or tracebacks, but I do see this: Publishing module Main Serving HTTP on port 8080 ... No core dumps that I can find. Python-1.5.1 (based on the Oli Andrich SRPMS, so the official patches are there), RedHat 5.1. Oh, btw, and I just realized I wasn't doing this either: When starting the server (serve.sh), python should be invoked with -u for unbuffered stdout and stderr I/O, unless this is being set somewhere within Zope (not sure how you would do this, though). I have my own xHTTPServer-based app, and logging works a lot better this way, particularly if you are writing to a pipe (which I am). My actual startup is: cd $ZOPEHOME env - PATH=$PATH \ supervise $ZOPEHOME/var/run /usr/bin/python -u serve.py 2>&1 \ | cyclog $ZOPEHOME/var/log & (supervise and cyclog are both in qmail's daemontools package. www.qmail.org) -- Andy Dustman You should always say "spam" and "eggs" ComStar Communications Corp. instead of "foo" and "bar" (706) 549-7689 | PGP KeyID=0xC72F3F1D in Python examples. (Mark Lutz)
I may have found the problem, although I really haven't replicated the problem in Zope. Rather, I found this was happening with another app of mine that uses the BaseHTTPServer.HTTPServer class. Examine ZopeHTTPServer.NonThreadingHTTPServer.handle_request: def handle_request(self): """Handle one request, possibly blocking.""" request, client_address = self.get_request() # BOOM! if self.verify_request(request, client_address): try: self.process_request(request, client_address) except SystemExit: self.handle_error(request, client_address) sys.exit(0) except: self.handle_error(request, client_address) If an exception is raised during the self.get_request() call, the server dies. What exceptions can happen? Well, get_request(), which is being inherited from way down in SocketServer.TCPServer, is simply returning self.socket.accept(). As it turs out, I have seen socket.error raised for "Peer reset connection". Probably this or some other socket.error is what mysterious killed Zope. What I don't understand, looking a little further down at the ThreadingHTTPServer, is why does it not have a similar handle_request method (it replicates server_bind)? Proposed fix: class NonThreadingHTTPServer(BaseHTTPServer.HTTPServer): "The normal HTTPServer with some socket tweaks" def server_bind(self): self.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) return BaseHTTPServer.HTTPServer.server_bind(self) def handle_request(self): """Handle one request, possibly blocking.""" request, client_address = None, None try: request, client_address = self.get_request() if self.verify_request(request, client_address): self.process_request(request, client_address) except SystemExit: self.handle_error(request, client_address) sys.exit(0) except: self.handle_error(request, client_address) class ThreadingHTTPServer(SocketServer.ThreadingMixIn, NonThreadingHTTPServer): pass I have tested this lightly and it appears to work. Both with and with -t threading option. Performance, BTW, is quite good, considering I'm testing on an old 80MHz 486 with 40MB RAM... -- Andy Dustman You should always say "spam" and "eggs" ComStar Communications Corp. instead of "foo" and "bar" (706) 549-7689 | PGP KeyID=0xC72F3F1D in Python examples. (Mark Lutz)
At 04:21 PM 12/11/98 -0500, Andy Dustman wrote:
I may have found the problem, although I really haven't replicated the problem in Zope. Rather, I found this was happening with another app of mine that uses the BaseHTTPServer.HTTPServer class. Examine ZopeHTTPServer.NonThreadingHTTPServer.handle_request: What I don't understand, looking a little further down at the ThreadingHTTPServer, is why does it not have a similar handle_request method (it replicates server_bind)? Proposed fix:
[fix snipped] I believe that it was an oversight not to have the same handle_request method for both single and multi threaded servers. Plus your fix for possible errors in get_request looks pretty reasonable. I'll add this to the pile of changes for ZopeHTTPServer. Thanks! -Amos
participants (2)
-
Amos Latteier -
Andy Dustman