Log message for revision 69861:
  merging ajung-fast-listen branch
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/ZServer/HTTPServer.py
  U   Zope/trunk/lib/python/ZServer/component.xml
  U   Zope/trunk/lib/python/ZServer/datatypes.py
  U   Zope/trunk/lib/python/Zope2/Startup/__init__.py
  U   Zope/trunk/skel/etc/zope.conf.in

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt  2006-08-29 15:51:39 UTC (rev 69860)
+++ Zope/trunk/doc/CHANGES.txt  2006-08-29 16:29:33 UTC (rev 69861)
@@ -27,6 +27,11 @@
 
     Features added
 
+      - added 'fast_listen' directive to http-server and webdav-source-server
+        sections in etc/zope.conf in order to defer the opening of the sockets
+        until the late startup phase. This in in particular useful when running
+        Zope behind a loadbalancer (patch by Patrick Gerken).
+
     Bugs Fixed
 
       - Collector #2155: Fix wrong parameter being passed to

Modified: Zope/trunk/lib/python/ZServer/HTTPServer.py
===================================================================
--- Zope/trunk/lib/python/ZServer/HTTPServer.py 2006-08-29 15:51:39 UTC (rev 
69860)
+++ Zope/trunk/lib/python/ZServer/HTTPServer.py 2006-08-29 16:29:33 UTC (rev 
69861)
@@ -428,8 +428,10 @@
     channel_class = zhttp_channel
     shutup=0
 
-    def __init__ (self, ip, port, resolver=None, logger_object=None):
+    def __init__ (self, ip, port, resolver=None, logger_object=None,
+                  fast_listen=True):
         self.shutup=1
+        self.fast_listen = fast_listen
         http_server.__init__(self, ip, port, resolver, logger_object)
         self.shutup=0
         self.log_info('%s server started at %s\n'
@@ -460,8 +462,13 @@
 
     def listen(self, num):
         # override asyncore limits for nt's listen queue size
-        self.accepting = 1
-        return self.socket.listen (num)
 
+        if self.fast_listen:
+            self.accepting = 1
+            return self.socket.listen (num)
+        else:
+            return 0
+
+
 class zwebdav_server(zhttp_server):
     server_protocol = 'WebDAV'

Modified: Zope/trunk/lib/python/ZServer/component.xml
===================================================================
--- Zope/trunk/lib/python/ZServer/component.xml 2006-08-29 15:51:39 UTC (rev 
69860)
+++ Zope/trunk/lib/python/ZServer/component.xml 2006-08-29 16:29:33 UTC (rev 
69861)
@@ -19,6 +19,12 @@
          receive WebDAV source responses to GET requests.
        </description>
      </key>
+     <key name="fast_listen" datatype="boolean" default="on">
+       <description>
+         Defines wether the http server should listen to requests immediatelly
+         or only after zope is ready to run
+       </description>
+     </key>
      <key name="use-wsgi" datatype="boolean" default="off" />
   </sectiontype>
 

Modified: Zope/trunk/lib/python/ZServer/datatypes.py
===================================================================
--- Zope/trunk/lib/python/ZServer/datatypes.py  2006-08-29 15:51:39 UTC (rev 
69860)
+++ Zope/trunk/lib/python/ZServer/datatypes.py  2006-08-29 16:29:33 UTC (rev 
69861)
@@ -70,6 +70,7 @@
         self.force_connection_close = section.force_connection_close
         # webdav-source-server sections won't have webdav_source_clients:
         webdav_clients = getattr(section, "webdav_source_clients", None)
+        self.fast_listen = getattr(section, 'fast_listen')
         self.webdav_source_clients = webdav_clients
         self.use_wsgi = section.use_wsgi
 
@@ -81,6 +82,7 @@
             handler.set_webdav_source_clients(self.webdav_source_clients)
         server = self.server_class(ip=self.ip, port=self.port,
                                    resolver=self.dnsresolver,
+                                   fast_listen=self.fast_listen,
                                    logger_object=access_logger)
         server.install_handler(handler)
         return server

Modified: Zope/trunk/lib/python/Zope2/Startup/__init__.py
===================================================================
--- Zope/trunk/lib/python/Zope2/Startup/__init__.py     2006-08-29 15:51:39 UTC 
(rev 69860)
+++ Zope/trunk/lib/python/Zope2/Startup/__init__.py     2006-08-29 16:29:33 UTC 
(rev 69861)
@@ -100,6 +100,7 @@
         self.makePidFile()
         self.setupInterpreter()
         self.startZope()
+        self.serverListen()
         from App.config import getConfiguration
         config = getConfiguration()
         if not config.twisted_servers:
@@ -211,6 +212,18 @@
         ZServer.setNumberOfThreads(self.cfg.zserver_threads)
         ZServer.CONNECTION_LIMIT = self.cfg.max_listen_sockets
 
+
+    def serverListen(self):
+
+       for server in self.cfg.servers:
+
+            if hasattr(server, 'fast_listen'):
+                # This one has the delayed listening feature
+                if not server.fast_listen:
+                    server.fast_listen = True
+                    server.listen(1024) # same value as defined in 
medusa.http_server.py  
+
+
     def setupServers(self):
         socket_err = (
             'There was a problem starting a server of type "%s". '

Modified: Zope/trunk/skel/etc/zope.conf.in
===================================================================
--- Zope/trunk/skel/etc/zope.conf.in    2006-08-29 15:51:39 UTC (rev 69860)
+++ Zope/trunk/skel/etc/zope.conf.in    2006-08-29 16:29:33 UTC (rev 69861)
@@ -903,9 +903,16 @@
 <http-server>
   # valid keys are "address" and "force-connection-close"
   address 8080
+
   # force-connection-close on
+  #
   # You can also use the WSGI interface between ZServer and ZPublisher:
   # use-wsgi on
+  #
+  # To defer the opening of the HTTP socket until the end of the 
+  # startup phase: 
+  # fast_listen false
+  #
 </http-server>
 
 # Examples:

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to