[CalendarServer-changes] [8395] CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/ tap/cfgchild.py

source_changes at macosforge.org source_changes at macosforge.org
Sat Dec 3 00:39:43 PST 2011


Revision: 8395
          http://trac.macosforge.org/projects/calendarserver/changeset/8395
Author:   glyph at apple.com
Date:     2011-12-03 00:39:42 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
automatically disable memcached as necessary, and propagate the right types of objects through to the subprocess

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/cfgchild.py

Modified: CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/cfgchild.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/cfgchild.py	2011-12-03 08:39:33 UTC (rev 8394)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/cfgchild.py	2011-12-03 08:39:42 UTC (rev 8395)
@@ -15,8 +15,8 @@
 ##
 
 """
-Tools for spawning general-purpose child processes that have a store devrived
-from a .
+Tools for spawning general-purpose child processes that have a store derived
+from an existing configuration.
 """
 
 __all__ = [
@@ -26,6 +26,7 @@
     'ConfiguredChildSpawner',
 ]
 
+from calendarserver.tools.util import autoDisableMemcached
 from twisted.python.reflect import namedAny, qual
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.protocols.amp import AMP, Command, String, Integer#, ListOf
@@ -74,7 +75,7 @@
         Optionally accept a configuration for testing, but normally created in
         the subprocess configuration-free.
         """
-        super(AMP, self).__init__()
+        super(ChildConfigurator, self).__init__()
         if config is None:
             from twistedcaldav.config import config
         self.config = config
@@ -93,12 +94,15 @@
         # Adjust the child's configuration to add all the relevant options for
         # the store that won't be mentioned in the config file.
         changedConfig = dict(
-            LogID            = logID,
-            PIDFile          = pidFile,
-            MultiProcess     = dict(
+            EnableCalDAV  = True,
+            EnableCardDAV = True,
+            LogID         = logID,
+            PIDFile       = pidFile,
+            MultiProcess  = dict(
                 ProcessCount = processCount
             )
         )
+        autoDisableMemcached(self.config)
         if connectionPoolFD is not None:
             changedConfig.update(DBAMPFD=connectionPoolFD)
         self.config.updateDefaults(changedConfig)
@@ -137,6 +141,7 @@
         @param config: the L{twistedcaldav.config.Config} to use to configure
             the subprocess.
         """
+        super(ConfiguredChildSpawner, self).__init__()
         self.nextID = 0
         self.maker = maker
         self.dispenser = dispenser
@@ -151,20 +156,31 @@
         thisID = self.nextID
         self.nextID += 1
         if self.dispenser is not None:
-            poolfd = self.dispenser.dispense()
-            childFDs = {poolfd: poolfd}
+            # NOTE: important and super subtle, 'poolskt' must not be GC'd
+            # until the call to spawn (and hence spawnProcess) below; otherwise
+            # that end of the socket will be closed and there will be nothing
+            # to inherit.
+            poolskt  = self.dispenser.dispense()
+            poolfd   = poolskt.fileno()
+            childFDs = {
+                0: "w", 1: "r", 2: "r", # behave like normal, but
+                poolfd: poolfd          # bonus FD
+            }
+            extra    = dict(connectionPoolFD=poolfd)
         else:
             childFDs = None
+            extra    = {}
         controller = yield self.spawn(
             AMP(), ChildConfigurator, childFDs=childFDs
         )
         yield controller.callRemote(
             ConfigureChild,
             delegateTo=qual(there),
-            pidfile="%s-migrator-%s" % (self.maker.tapname, thisID),
+            pidFile="%s-migrator-%s" % (self.maker.tapname, thisID),
             logID="migrator-%s" % (thisID,),
             configFile=self.config.getProvider().getConfigFileName(),
-            processCount=self.config.MultiProcess.processCount,
+            processCount=self.config.MultiProcess.ProcessCount,
+            **extra
         )
         returnValue(swapAMP(controller, here))
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/19747817/attachment-0001.html>


More information about the calendarserver-changes mailing list