[CalendarServer-changes] [1399]
CalendarServer/trunk/twistedcaldav/cluster.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 15 18:06:55 PDT 2007
Revision: 1399
http://trac.macosforge.org/projects/calendarserver/changeset/1399
Author: dreid at apple.com
Date: 2007-03-15 18:06:55 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
Make the loadbalancer in the Combined service support Bind*Ports
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/cluster.py
Modified: CalendarServer/trunk/twistedcaldav/cluster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cluster.py 2007-03-15 21:22:25 UTC (rev 1398)
+++ CalendarServer/trunk/twistedcaldav/cluster.py 2007-03-16 01:06:55 UTC (rev 1399)
@@ -30,7 +30,7 @@
serviceTemplate = """
<service name="%(name)s">
- <listen ip="%(bindAddress)s:%(port)s" />
+ %(listeningInterfaces)s
<group name="main" scheduler="%(scheduler)s">
%(hosts)s
</group>
@@ -44,6 +44,8 @@
</pdconfig>
"""
+listenTemplate = '<listen ip="%(bindAddress)s:%(port)s" />'
+
hostTemplate = '<host name="%(name)s" ip="%(bindAddress)s:%(port)s" />'
@@ -82,7 +84,7 @@
'-o', 'BindSSLPorts=%s' % (self.sslPort,),
'-o', 'PIDFile=None',
'-o', 'ErrorLogFile=None']
-
+
def getHostLine(self, ssl=None):
name = self.getName()
port = self.port
@@ -97,7 +99,7 @@
def makeService_Combined(self, options):
service = procmon.ProcessMonitor()
-
+
parentEnv = {'PYTHONPATH': os.environ.get('PYTHONPATH', ''),}
hosts = []
@@ -137,14 +139,14 @@
service.addProcess(process.getName(),
process.getCommandLine(),
env=parentEnv)
-
+
if config.HTTPPort:
hosts.append(process.getHostLine())
if config.SSLPort:
sslHosts.append(process.getHostLine(ssl=True))
- if (config.MultiProcess['LoadBalancer']['Enabled'] and
+ if (config.MultiProcess['LoadBalancer']['Enabled'] and
config.MultiProcess['ProcessCount'] > 1):
services = []
@@ -158,20 +160,30 @@
}
for bindAddress in config.BindAddresses:
- if config.HTTPPort:
+ httpListeners = []
+ sslListeners = []
+
+ for ports, listeners in ((config.BindHTTPPorts, httpListeners),
+ (config.BindSSLPorts, sslListeners)):
+ for port in ports:
+ listeners.append(listenTemplate % {
+ 'bindAddress': bindAddress,
+ 'port': port})
+
+ if config.BindHTTPPorts:
services.append(serviceTemplate % {
'name': 'http',
+ 'listeningInterfaces': '\n'.join(httpListeners),
'bindAddress': bindAddress,
- 'port': config.HTTPPort,
'scheduler': scheduler_map[config.MultiProcess['LoadBalancer']['Scheduler']],
'hosts': '\n'.join(hosts)
})
-
- if config.SSLPort:
+
+ if config.BindSSLPorts:
services.append(serviceTemplate % {
'name': 'https',
+ 'listeningInterfaces': '\n'.join(sslListeners),
'bindAddress': bindAddress,
- 'port': config.SSLPort,
'scheduler': scheduler_map[config.MultiProcess['LoadBalancer']['Scheduler']],
'hosts': '\n'.join(sslHosts),
})
@@ -179,18 +191,18 @@
pdconfig = configTemplate % {
'services': '\n'.join(services),
}
-
+
fd, fname = tempfile.mkstemp(prefix='pydir')
os.write(fd, pdconfig)
os.close(fd)
-
+
log.msg("Adding pydirector service with configuration: %s" % (fname,))
service.addProcess('pydir', [sys.executable,
config.PythonDirector['pydir'],
fname],
env=parentEnv)
-
+
return service
def makeService_Master(self, options):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070315/3a7ec9b9/attachment.html
More information about the calendarserver-changes
mailing list