[CalendarServer-changes] [2956] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 9 12:36:53 PDT 2008


Revision: 2956
          http://trac.macosforge.org/projects/calendarserver/changeset/2956
Author:   wsanchez at apple.com
Date:     2008-09-09 12:36:52 -0700 (Tue, 09 Sep 2008)
Log Message:
-----------
Merge branches/users/cdaboo/staggerstart-2918

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/cluster.py
    CalendarServer/trunk/twistedcaldav/config.py
    CalendarServer/trunk/twistedcaldav/tap.py

Modified: CalendarServer/trunk/twistedcaldav/cluster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cluster.py	2008-09-09 18:49:45 UTC (rev 2955)
+++ CalendarServer/trunk/twistedcaldav/cluster.py	2008-09-09 19:36:52 UTC (rev 2956)
@@ -20,6 +20,7 @@
 
 from twisted.runner import procmon
 from twisted.application import internet, service
+from twisted.internet import reactor, process
 
 from twistedcaldav.accesslog import AMPLoggingFactory, RotatingFileAccessLoggingObserver
 from twistedcaldav.config import config, ConfigurationError
@@ -141,10 +142,55 @@
                                'bindAddress': '127.0.0.1'}
 
 
+class DelayedStartupProcessMonitor(procmon.ProcessMonitor):
+
+    def startService(self):
+        service.Service.startService(self)
+        self.active = 1
+        delay = 0
+        delay_interval = config.MultiProcess['StaggeredStartup']['Interval'] if config.MultiProcess['StaggeredStartup']['Enabled'] else 0 
+        for name in self.processes.keys():
+            reactor.callLater(delay if name.startswith("caldav") else 0, self.startProcess, name)
+            if name.startswith("caldav"):
+                delay += delay_interval
+        self.consistency = reactor.callLater(self.consistencyDelay,
+                                             self._checkConsistency)
+
+    def signalAll(self, signal, startswithname=None):
+        """
+        Send a signal to all child processes.
+
+        @param signal: the signal to send
+        @type signal: C{int}
+        @param startswithname: is set only signal those processes whose name starts with this string
+        @type signal: C{str}
+        """
+        for name in self.processes.keys():
+            if startswithname is None or name.startswith(startswithname):
+                self.signalProcess(signal, name)
+
+    def signalProcess(self, signal, name):
+        """
+        Send a signal to each monitored process
+        
+        @param signal: the signal to send
+        @type signal: C{int}
+        @param startswithname: is set only signal those processes whose name starts with this string
+        @type signal: C{str}
+        """
+        if not self.protocols.has_key(name):
+            return
+        proc = self.protocols[name].transport
+        try:
+            proc.signalProcess(signal)
+        except process.ProcessExitedAlready:
+            pass
+
 def makeService_Combined(self, options):
     s = service.MultiService()
-    monitor = procmon.ProcessMonitor()
+    monitor = DelayedStartupProcessMonitor()
     monitor.setServiceParent(s)
+    s.processMonitor = monitor
 
     parentEnv = {
         'PATH': os.environ.get('PATH', ''),

Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py	2008-09-09 18:49:45 UTC (rev 2955)
+++ CalendarServer/trunk/twistedcaldav/config.py	2008-09-09 19:36:52 UTC (rev 2956)
@@ -161,6 +161,10 @@
             "Enabled": True,
             "Scheduler": "LeastConnections",
         },
+        "StaggeredStartup": {
+            "Enabled": False,
+            "Interval": 15,
+        },
     },
 
     #
@@ -517,6 +521,8 @@
             configDict = readPlist(configFile)
             configDict = _cleanup(configDict)
             self.update(configDict)
+        elif configFile:
+            log.error("Configuration file does not exist or is inaccessible: %s" % (configFile,))
 
     @staticmethod
     def updateNotifications(self, items):

Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py	2008-09-09 18:49:45 UTC (rev 2955)
+++ CalendarServer/trunk/twistedcaldav/tap.py	2008-09-09 19:36:52 UTC (rev 2956)
@@ -783,6 +783,10 @@
                 # Reload the config file
                 config.reload()
 
+                # If combined service send signal to all caldavd children
+                if serverType == "Combined":
+                    service.processMonitor.signalAll(signal.SIGHUP, "caldav")
+
                 # FIXME: There is no memcachepool.getCachePool
                 #   Also, better option is probably to add a hook to
                 #   the config object instead of doing things here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080909/15eb6407/attachment.html 


More information about the calendarserver-changes mailing list