[CalendarServer-changes] [2921] CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Sun Aug 31 07:51:03 PDT 2008


Revision: 2921
          http://trac.macosforge.org/projects/calendarserver/changeset/2921
Author:   cdaboo at apple.com
Date:     2008-08-31 07:51:01 -0700 (Sun, 31 Aug 2008)
Log Message:
-----------
Allow SIGHUP to propagate from parent to child caldavd processes.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/cluster.py
    CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/tap.py

Modified: CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/cluster.py
===================================================================
--- CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/cluster.py	2008-08-30 03:31:08 UTC (rev 2920)
+++ CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/cluster.py	2008-08-31 14:51:01 UTC (rev 2921)
@@ -20,7 +20,7 @@
 
 from twisted.runner import procmon
 from twisted.application import internet, service
-from twisted.internet import reactor
+from twisted.internet import reactor, process
 
 from twistedcaldav.accesslog import AMPLoggingFactory, RotatingFileAccessLoggingObserver
 from twistedcaldav.config import config, ConfigurationError
@@ -156,11 +156,41 @@
         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 = DelayedStartupProcessMonitor()
     monitor.setServiceParent(s)
+    s.processMonitor = monitor
 
     parentEnv = {
         'PATH': os.environ.get('PATH', ''),

Modified: CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/tap.py
===================================================================
--- CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/tap.py	2008-08-30 03:31:08 UTC (rev 2920)
+++ CalendarServer/branches/users/cdaboo/staggerstart-2918/twistedcaldav/tap.py	2008-08-31 14:51:01 UTC (rev 2921)
@@ -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/20080831/6bde13dd/attachment.html 


More information about the calendarserver-changes mailing list