Commit 12f0321c authored by Andreas Jung's avatar Andreas Jung

merging ajung-fast-listen branch

parent 778ad970
......@@ -27,6 +27,11 @@ Zope Changes
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
......
......@@ -428,8 +428,10 @@ class zhttp_server(http_server):
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 @@ class zhttp_server(http_server):
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'
......@@ -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>
......
......@@ -70,6 +70,7 @@ class HTTPServerFactory(ServerFactory):
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 @@ class HTTPServerFactory(ServerFactory):
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
......
......@@ -100,6 +100,7 @@ class ZopeStarter:
self.makePidFile()
self.setupInterpreter()
self.startZope()
self.serverListen()
from App.config import getConfiguration
config = getConfiguration()
if not config.twisted_servers:
......@@ -211,6 +212,18 @@ class ZopeStarter:
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". '
......
......@@ -903,9 +903,16 @@ instancehome $INSTANCE
<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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment