[CalendarServer-changes] [1253] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 23 15:19:09 PST 2007


Revision: 1253
          http://trac.macosforge.org/projects/calendarserver/changeset/1253
Author:   wsanchez at apple.com
Date:     2007-02-23 15:19:09 -0800 (Fri, 23 Feb 2007)

Log Message:
-----------
Clean up processing options.

Modified Paths:
--------------
    CalendarServer/trunk/bin/caldavd
    CalendarServer/trunk/conf/caldavd-test-logged.plist
    CalendarServer/trunk/conf/caldavd-test.plist
    CalendarServer/trunk/conf/caldavd.plist
    CalendarServer/trunk/run
    CalendarServer/trunk/twistedcaldav/cluster.py
    CalendarServer/trunk/twistedcaldav/config.py
    CalendarServer/trunk/twistedcaldav/tap.py

Modified: CalendarServer/trunk/bin/caldavd
===================================================================
--- CalendarServer/trunk/bin/caldavd	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/bin/caldavd	2007-02-23 23:19:09 UTC (rev 1253)
@@ -87,7 +87,7 @@
     echo "        -g Group name to run as";
     echo "        -f Configuration file to read";
     echo "        -T Path to twistd binary";
-    echo "        -t Service type (master, slave, standalone, cluster)";
+    echo "        -t Process type (Master, Slave or Combined)";
     
     if [ "${1-}" == "-" ]; then return 0; fi;
     exit 64;

Modified: CalendarServer/trunk/conf/caldavd-test-logged.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test-logged.plist	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/conf/caldavd-test-logged.plist	2007-02-23 23:19:09 UTC (rev 1253)
@@ -197,27 +197,12 @@
   <string>conf/sudoers.plist</string>
   
   <key>ProcessType</key>
-  <string>singleprocess</string>
+  <string>Slave</string>
   
   <key>MultiProcess</key>
   <dict>
-    <key>NumProcesses</key>
+    <key>ProcessCount</key>
     <integer>2</integer>
-
-    <key>LoadBalancer</key>
-    <dict>
-      <key>Enabled</key>
-      <true/>
-
-      <key>Scheduler</key>
-      <!-- Least Connections -->
-      <string>leastconns</string>
-      <!-- Round Robin -->
-      <!-- <string>roundrobin</string> -->
-      <!-- Least Connections and Round Robin -->
-      <!-- <string>leastconnsrr</string> -->
-
-    </dict>    
   </dict>
 
   <key>pydirLocation</key>

Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/conf/caldavd-test.plist	2007-02-23 23:19:09 UTC (rev 1253)
@@ -197,27 +197,12 @@
   <string>conf/sudoers.plist</string>
   
   <key>ProcessType</key>
-  <string>singleprocess</string>
+  <string>Slave</string>
   
   <key>MultiProcess</key>
   <dict>
-    <key>NumProcesses</key>
+    <key>ProcessCount</key>
     <integer>2</integer>
-
-    <key>LoadBalancer</key>
-    <dict>
-      <key>Enabled</key>
-      <true/>
-
-      <key>Scheduler</key>
-      <!-- Least Connections -->
-      <string>leastconns</string>
-      <!-- Round Robin -->
-      <!-- <string>roundrobin</string> -->
-      <!-- Least Connections and Round Robin -->
-      <!-- <string>leastconnsrr</string> -->
-
-    </dict>    
   </dict>
 
   <key>pydirLocation</key>

Modified: CalendarServer/trunk/conf/caldavd.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd.plist	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/conf/caldavd.plist	2007-02-23 23:19:09 UTC (rev 1253)
@@ -149,26 +149,12 @@
   <key>SudoersFile</key>
   <string>/etc/caldavd/sudoers.plist</string>
   <key>ProcessType</key>
-  <string>multiprocess</string>
+  <string>Combined</string>
   
   <key>MultiProcess</key>
   <dict>
-    <key>NumProcesses</key>
+    <key>ProcessCount</key>
     <integer>1</integer>
-
-    <key>LoadBalancer</key>
-    <dict>
-      <key>Enabled</key>
-      <false/>
-
-      <key>Scheduler</key>
-      <!-- Least Connections -->
-      <string>leastconns</string>
-      <!-- Round Robin -->
-      <!-- <string>roundrobin</string> -->
-      <!-- Least Connections and Round Robin -->
-      <!-- <string>leastconnsrr</string> -->
-    </dict>    
   </dict>
 
   <key>pydirLocation</key>

Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/run	2007-02-23 23:19:09 UTC (rev 1253)
@@ -35,7 +35,7 @@
       install="";
     daemonize="-X";
   plugin_name="caldav";
- service_type="singleprocess";
+ service_type="Slave";
 
 usage ()
 {
@@ -54,7 +54,7 @@
   echo "        -d  Run caldavd as a daemon";
   echo "        -i  Perform a system install into dst; implies -s";
   echo "        -I  Perform a home install into dst; implies -s";
-  echo "        -t  Select the type of server to run (singleprocess, multiprocess, or master)";
+  echo "        -t  Select the server process type (Master, Slave or Combined)";
 
   if [ "${1-}" == "-" ]; then return 0; fi;
   exit 64;

Modified: CalendarServer/trunk/twistedcaldav/cluster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cluster.py	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/twistedcaldav/cluster.py	2007-02-23 23:19:09 UTC (rev 1253)
@@ -72,7 +72,7 @@
             '-g', config.GroupName,
             '-n', 'caldav',
             '-f', self.configFile,
-            '-o', 'ProcessType=slave',
+            '-o', 'ProcessType=Slave',
             '-o', 'BindAddresses=%s' % (','.join(self.interfaces),),
             '-o', 'BindHTTPPorts=%s' % (self.port,),
             '-o', 'BindSSLPorts=%s' % (self.sslPort,),
@@ -91,7 +91,7 @@
                                'port': port,
                                'bindAddress': '127.0.0.1'}
 
-def makeService_multiprocess(self, options):
+def makeService_Combined(self, options):
     service = procmon.ProcessMonitor()
     
     parentEnv = {'PYTHONPATH': os.environ.get('PYTHONPATH', ''),}
@@ -107,8 +107,8 @@
     if not config.MultiProcess['LoadBalancer']['Enabled']:
         bindAddress = config.BindAddresses
 
-    for p in xrange(0, config.MultiProcess['NumProcesses']):
-        if int(config.MultiProcess['NumProcesses']) > 1:
+    for p in xrange(0, config.MultiProcess['ProcessCount']):
+        if int(config.MultiProcess['ProcessCount']) > 1:
             port += 1
             sslport += 1
 
@@ -128,20 +128,25 @@
             sslHosts.append(process.getHostLine(ssl=True))
 
     if (config.MultiProcess['LoadBalancer']['Enabled'] and 
-        config.MultiProcess['NumProcesses'] > 1):
+        config.MultiProcess['ProcessCount'] > 1):
         services = []
 
         if not config.BindAddresses:
             config.BindAddresses = ['']
 
+        scheduler_map = {
+            "LeastConnections": "leastconns",
+            "RoundRobin": "roundrobin",
+            "LeastConnectionsAndRoundRobin": "leastconnsrr",
+        }
+
         for bindAddress in config.BindAddresses:
             if config.HTTPPort:
                 services.append(serviceTemplate % {
                         'name': 'http',
                         'bindAddress': bindAddress,
                         'port': config.HTTPPort,
-                        'scheduler': 
-                        config.MultiProcess['LoadBalancer']['Scheduler'],
+                        'scheduler': scheduler_map[config.MultiProcess['LoadBalancer']['Scheduler']],
                         'hosts': '\n'.join(hosts)
                         })
             
@@ -150,8 +155,7 @@
                         'name': 'https',
                         'bindAddress': bindAddress,
                         'port': config.SSLPort,
-                        'scheduler': 
-                        config.MultiProcess['LoadBalancer']['Scheduler'],
+                        'scheduler': scheduler_map[config.MultiProcess['LoadBalancer']['Scheduler']],
                         'hosts': '\n'.join(sslHosts),
                         })
 
@@ -172,7 +176,7 @@
     
     return service
 
-def makeService_pydir(self, options):
+def makeService_Master(self, options):
     service = procmon.ProcessMonitor()
 
     parentEnv = {'PYTHONPATH': os.environ.get('PYTHONPATH', ''),}

Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/twistedcaldav/config.py	2007-02-23 23:19:09 UTC (rev 1253)
@@ -101,12 +101,12 @@
     #
     "UserName": "daemon",
     "GroupName": "daemon",
-    "ProcessType": "singleprocess",
+    "ProcessType": "Slave",
     "MultiProcess": {
-        "NumProcesses": 10,
+        "ProcessCount": 10,
         "LoadBalancer": {
             "Enabled": True,
-            "Scheduler": "leastconns",
+            "Scheduler": "LeastConnections",
         },
     },
 
@@ -130,7 +130,6 @@
 
     # Twisted
     "twistdLocation": "/usr/share/caldavd/bin/twistd",
-    "ManholePort": 0, # Port number to bind to for Twisted manhole (debugging) [0 = none]
 
     # Python Director
     "pydirLocation": "/usr/share/caldavd/bin/pydir++.py",

Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py	2007-02-23 21:31:19 UTC (rev 1252)
+++ CalendarServer/trunk/twistedcaldav/tap.py	2007-02-23 23:19:09 UTC (rev 1253)
@@ -43,7 +43,7 @@
 from twisted.web2.log import LogWrapperResource
 from twisted.web2.server import Site
 
-from twistedcaldav.cluster import makeService_multiprocess, makeService_pydir
+from twistedcaldav.cluster import makeService_Combined, makeService_Master
 from twistedcaldav.config import config, parseConfig, defaultConfig, ConfigurationError
 from twistedcaldav.logging import RotatingFileAccessLoggingObserver
 from twistedcaldav.root import RootResource
@@ -75,11 +75,10 @@
 
 
 class CalDAVOptions(Options):
-    optParameters = [
-        ["config", "f", "/etc/caldavd/caldavd.plist",
-         "Path to configuration file."],
-        ]
-        
+    optParameters = [[
+        "config", "f", "/etc/caldavd/caldavd.plist", "Path to configuration file."
+    ]]
+
     zsh_actions = {"config" : "_files -g '*.plist'"}
 
     def __init__(self, *args, **kwargs):
@@ -109,8 +108,7 @@
                     value = value.split(',')
 
                 elif isinstance(defaultConfig[key], dict):
-                    raise UsageError(
-                        "We do not support dict options on the command line")
+                    raise UsageError("Dict options not supported on the command line")
                         
                 elif value == 'None':
                     value = None
@@ -139,15 +137,15 @@
             if uid != os.getuid() and os.getuid() != 0:
                 import pwd
                 username = pwd.getpwuid(os.getuid())[0]
-                raise UsageError(("Only root can drop privileges "
-                                  "you are: %r" % (username,)))
+                raise UsageError("Only root can drop privileges you are: %r"
+                                 % (username,))
 
         if gid:
             if gid != os.getgid() and os.getgid() != 0:
                 import grp
                 groupname = grp.getgrgid(os.getuid())[0]
-                raise UsageError(("Only root can drop privileges, "
-                                  "you are: %s" % (groupname,)))
+                raise UsageError("Only root can drop privileges, you are: %s"
+                                 % (groupname,))
 
         self.parent['logfile'] = config.ErrorLogFile
         self.parent['pidfile'] = config.PIDFile
@@ -159,7 +157,8 @@
             access=os.R_OK or os.W_OK,
             permissions=0750,
             uname=config.UserName,
-            gname=config.GroupName)
+            gname=config.GroupName
+        )
             
         # Verify that ssl certs exist if needed
         if config.SSLPort:
@@ -167,21 +166,22 @@
                 config.SSLPrivateKey,
                 "SSL Private key",
                 access=os.R_OK,
-                permissions=0640)
+                permissions=0640
+            )
             self.checkFile(
                 config.SSLCertificate,
                 "SSL Public key",
                 access=os.R_OK,
-                permissions=0644)
+                permissions=0644
+            )
 
         #
         # Nuke the file log observer's time format.
         #
 
-        if not config.ErrorLogFile and config.ProcessType == 'slave':
+        if not config.ErrorLogFile and config.ProcessType == 'Slave':
             log.FileLogObserver.timeFormat = ''
         
-        
         # Check current umask and warn if changed
         oldmask = os.umask(0027)
         if oldmask != 0027:
@@ -215,29 +215,29 @@
         pathstat = os.stat(path)
         if permissions:
             if stat.S_IMODE(pathstat[stat.ST_MODE]) != permissions:
-                raiseOrPrint("The permisions on %s directory %s are 0%03o and do not match expected permissions: 0%03o" % \
-                             (description, path, stat.S_IMODE(pathstat[stat.ST_MODE]), permissions))
+                raiseOrPrint("The permisions on %s directory %s are 0%03o and do not match expected permissions: 0%03o"
+                             % (description, path, stat.S_IMODE(pathstat[stat.ST_MODE]), permissions))
         if uname:
             import pwd
             try:
                 pathuname = pwd.getpwuid(pathstat[stat.ST_UID])[0]
                 if pathuname != uname:
-                    raiseOrPrint("The owner of %s directory %s is %s and does not match the expected owner: %s" % \
-                                 (description, path, pathuname, uname))
+                    raiseOrPrint("The owner of %s directory %s is %s and does not match the expected owner: %s"
+                                 % (description, path, pathuname, uname))
             except KeyError:
-                raiseOrPrint("The owner of %s directory %s is unknown (%s) and does not match the expected owner: %s" % \
-                             (description, path, pathstat[stat.ST_UID], uname))
+                raiseOrPrint("The owner of %s directory %s is unknown (%s) and does not match the expected owner: %s"
+                             % (description, path, pathstat[stat.ST_UID], uname))
                     
         if gname:
             import grp
             try:
                 pathgname = grp.getgrgid(pathstat[stat.ST_GID])[0]
                 if pathgname != gname:
-                    raiseOrPrint("The group of %s directory %s is %s and does not match the expected group: %s" % \
-                                 (description, path, pathgname, gname))
+                    raiseOrPrint("The group of %s directory %s is %s and does not match the expected group: %s"
+                                 % (description, path, pathgname, gname))
             except KeyError:
-                raiseOrPrint("The group of %s directory %s is unknown (%s) and does not match the expected group: %s" % \
-                             (description, path, pathstat[stat.ST_GID], gname))
+                raiseOrPrint("The group of %s directory %s is unknown (%s) and does not match the expected group: %s"
+                             % (description, path, pathstat[stat.ST_GID], gname))
                     
 
 class CalDAVServiceMaker(object):
@@ -253,11 +253,11 @@
     # default resource classes
     #
 
-    rootResourceClass = RootResource
+    rootResourceClass      = RootResource
     principalResourceClass = DirectoryPrincipalProvisioningResource
-    calendarResourceClass = CalendarHomeProvisioningFile
+    calendarResourceClass  = CalendarHomeProvisioningFile
 
-    def makeService_singleprocess(self, options):
+    def makeService_Slave(self, options):
         #
         # Setup the Directory
         #
@@ -265,8 +265,8 @@
         
         directoryClass = namedClass(config.DirectoryService['type'])
         
-        log.msg("Configuring directory service of type: %s" % (
-            config.DirectoryService['type'],))
+        log.msg("Configuring directory service of type: %s"
+                % (config.DirectoryService['type'],))
         
         baseDirectory = directoryClass(**config.DirectoryService['params'])
 
@@ -275,8 +275,8 @@
         sudoDirectory = None
 
         if config.SudoersFile and os.path.exists(config.SudoersFile):
-            log.msg("Configuring SudoDirectoryService with file: %s" % (
-                config.SudoersFile,))
+            log.msg("Configuring SudoDirectoryService with file: %s"
+                    % (config.SudoersFile,))
                 
             sudoDirectory = SudoDirectoryService(config.SudoersFile)
             sudoDirectory.realmName = baseDirectory.realmName
@@ -284,9 +284,8 @@
             CalDAVResource.sudoDirectory = sudoDirectory
             directories.append(sudoDirectory)
         else:
-            log.msg(
-                "Not using SudoDirectoryService; file doesn't exist: %s" % (
-                config.SudoersFile,))
+            log.msg("Not using SudoDirectoryService; file doesn't exist: %s"
+                    % (config.SudoersFile,))
 
         directory = AggregateDirectoryService(directories)
 
@@ -300,8 +299,7 @@
 
         log.msg("Setting up document root at: %s" % (config.DocumentRoot,))
         
-        log.msg("Setting up principal collection: %r" % (
-            self.principalResourceClass,))
+        log.msg("Setting up principal collection: %r" % (self.principalResourceClass,))
 
         principalCollection = self.principalResourceClass(
             os.path.join(config.DocumentRoot, 'principals'),
@@ -309,8 +307,7 @@
             directory
         )
 
-        log.msg("Setting up calendar collection: %r" % (
-            self.calendarResourceClass,))
+        log.msg("Setting up calendar collection: %r" % (self.calendarResourceClass,))
 
         calendarCollection = self.calendarResourceClass(
             os.path.join(config.DocumentRoot, 'calendars'),
@@ -386,11 +383,14 @@
 
                     credFactory = NegotiateCredentialFactory(
                         schemeConfig['ServicePrincipal'],
-                        schemeConfig['Realm'],)
+                        schemeConfig['Realm'],
+                    )
 
                 elif scheme == 'digest':
                     credFactory = DigestCredentialFactory(
-                        schemeConfig['Algorithm'], realm)
+                        schemeConfig['Algorithm'],
+                        realm
+                    )
 
                 elif scheme == 'basic':
                     credFactory = BasicCredentialFactory(realm)
@@ -407,7 +407,8 @@
             root,
             portal,
             credentialFactories,
-            (auth.IPrincipal,))
+            (auth.IPrincipal,)
+        )
 
         site = Site(LogWrapperResource(authWrapper))
 
@@ -463,19 +464,16 @@
             
         return service
 
-    makeService_slave        = makeService_singleprocess
-    makeService_multiprocess = makeService_multiprocess
-    makeService_master       = makeService_pydir
+    makeService_Combined = makeService_Combined
+    makeService_Master   = makeService_Master
 
     def makeService(self, options):
         serverType = config.ProcessType
-        
+
         serviceMethod = getattr(self, "makeService_%s" % (serverType,), None)
 
         if not serviceMethod:
-            raise UsageError(
-                "Unknown server type %s, please choose: singleprocess, "
-                "multiprocess, master, slave" % (serverType,)
-            )
+            raise UsageError("Unknown server type %s.  Please choose: Master, Slave or Combined"
+                             % (serverType,))
         else:
             return serviceMethod(options)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070223/fbfed7ff/attachment.html


More information about the calendarserver-changes mailing list