[CalendarServer-changes] [14702] CalendarServer/branches/release/CalendarServer-6.1-dev

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 23 19:56:28 PDT 2015


Revision: 14702
          http://trac.calendarserver.org//changeset/14702
Author:   sagen at apple.com
Date:     2015-04-23 19:56:27 -0700 (Thu, 23 Apr 2015)
Log Message:
-----------
Post an alert if server root is unavailable and wait

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py
    CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/util.py
    CalendarServer/branches/release/CalendarServer-6.1-dev/conf/caldavd-apple.plist
    CalendarServer/branches/release/CalendarServer-6.1-dev/twistedcaldav/stdconfig.py

Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py	2015-04-23 18:58:21 UTC (rev 14701)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py	2015-04-24 02:56:27 UTC (rev 14702)
@@ -25,6 +25,7 @@
     "getRootResource",
     "getSSLPassphrase",
     "MemoryLimitService",
+    "postAlert",
     "preFlightChecks",
 ]
 
@@ -1445,3 +1446,23 @@
                 return output.strip()
 
     return None
+
+
+def postAlert(alertType, args):
+    if (
+        config.AlertPostingProgram and
+        os.path.exists(config.AlertPostingProgram)
+    ):
+        try:
+            commandLine = [config.AlertPostingProgram, alertType]
+            commandLine.extend(args)
+            Popen(
+                commandLine,
+                stdout=PIPE,
+                stderr=PIPE,
+            ).communicate()
+        except Exception, e:
+            log.error(
+                "Could not post alert: {alertType} {args} ({error})",
+                alertType=alertType, args=args, error=e
+            )

Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/util.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/util.py	2015-04-23 18:58:21 UTC (rev 14701)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/util.py	2015-04-24 02:56:27 UTC (rev 14702)
@@ -140,9 +140,16 @@
     if not os.path.exists(dirpath):
 
         if wait:
+
+            # If we're being told to wait, post an alert that we can't continue
+            # until the volume is mounted
+            if not os.path.exists(dirpath):
+                from calendarserver.tap.util import postAlert
+                postAlert("MissingDataVolumeAlert", ["volumePath", dirpath])
+
             while not os.path.exists(dirpath):
                 print("Path does not exist: %s" % (dirpath,))
-                sleep(1)
+                sleep(5)
         else:
             try:
                 mode, username, groupname = create

Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/conf/caldavd-apple.plist
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/conf/caldavd-apple.plist	2015-04-23 18:58:21 UTC (rev 14701)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/conf/caldavd-apple.plist	2015-04-24 02:56:27 UTC (rev 14702)
@@ -556,6 +556,12 @@
       <true/>
     </dict>
 
+    <!-- Alert-posting program
+      -->
+    <key>AlertPostingProgram</key>
+    <string>/Applications/Server.app/Contents/ServerRoot/Library/CalendarServer/bin/calendarserver_alert</string>
+
+
     <key>Includes</key>
     <array>
         <string>/Library/Preferences/com.apple.servermgr_calendar.plist</string>

Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/twistedcaldav/stdconfig.py	2015-04-23 18:58:21 UTC (rev 14701)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/twistedcaldav/stdconfig.py	2015-04-24 02:56:27 UTC (rev 14702)
@@ -1064,6 +1064,10 @@
     # respawning it.  Empty string to disable this feature.
     "ServiceDisablingProgram": "",
 
+    # Program to execute to post an alert to the administrator; for example in
+    # OS X we want to call calendarserver_alert <alert-type> <args>
+    "AlertPostingProgram": "",
+
     # These three keys are relative to ConfigRoot:
 
     # Config to read first and merge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150423/6403d3ae/attachment.html>


More information about the calendarserver-changes mailing list