[CalendarServer-changes] [13811] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 31 16:22:20 PDT 2014
Revision: 13811
http://trac.calendarserver.org//changeset/13811
Author: sagen at apple.com
Date: 2014-07-31 16:22:20 -0700 (Thu, 31 Jul 2014)
Log Message:
-----------
Calls a service-disabling program if we can't create the store
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/contrib/launchd/calendarserver.plist
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2014-07-31 21:05:16 UTC (rev 13810)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2014-07-31 23:22:20 UTC (rev 13811)
@@ -28,7 +28,7 @@
from os.path import exists, basename, isfile
import socket
from stat import S_ISSOCK
-from time import time
+import time
from subprocess import Popen, PIPE
from pwd import getpwuid, getpwnam
from grp import getgrnam
@@ -682,6 +682,26 @@
0, service.setServiceParent, self.parent
)
except StoreNotAvailable:
+ log.error("Data store not available; shutting down")
+
+ if config.ServiceDisablingProgram:
+ # If the store is not available, we don't want launchd to
+ # repeatedly launch us, we want our job to get unloaded.
+ # If the config.ServiceDisablingProgram is assigned and exists
+ # we execute it now. Its job is to carry out the platform-
+ # specific tasks of disabling the service.
+ if exists(config.ServiceDisablingProgram):
+ log.error(
+ "Disabling service via {exe}",
+ exe=config.ServiceDisablingProgram
+ )
+ Popen(
+ args=[config.ServiceDisablingProgram],
+ stdout=PIPE,
+ stderr=PIPE,
+ ).communicate()
+ time.sleep(60)
+
self.reactor.stop()
return succeed(None)
@@ -707,13 +727,6 @@
-class PostUpgradeStopRequested(Exception):
- """
- Raised when we've been asked to stop just after upgrade has completed.
- """
-
-
-
class StoreNotAvailable(Exception):
"""
Raised when we want to give up because the store is not available
@@ -2447,7 +2460,7 @@
p.service = self
p.name = name
procObj, env, uid, gid = self.processes[name]
- self.timeStarted[name] = time()
+ self.timeStarted[name] = time.time()
childFDs = {0: "w", 1: "r", 2: "r"}
@@ -2504,7 +2517,7 @@
if uidgid:
uidgid = '(' + uidgid + ')'
- l.append("{:r}{}: {:r}".format(name, uidgid, procObj))
+ l.append("{}{}: {}".format(name, uidgid, procObj))
return (
"<{self.__class__.__name__} {l}>"
Modified: CalendarServer/trunk/contrib/launchd/calendarserver.plist
===================================================================
--- CalendarServer/trunk/contrib/launchd/calendarserver.plist 2014-07-31 21:05:16 UTC (rev 13810)
+++ CalendarServer/trunk/contrib/launchd/calendarserver.plist 2014-07-31 23:22:20 UTC (rev 13811)
@@ -34,6 +34,8 @@
<string>kqueue</string>
<string>-o</string>
<string>FailIfUpgradeNeeded=False</string>
+ <string>-o</string>
+ <string>ServiceDisablingProgram=/Applications/Server.app/Contents/ServerRoot/Library/CalendarServer/bin/calendarserver_stop
</array>
<key>EnvironmentVariables</key>
@@ -44,7 +46,7 @@
<key>InitGroups</key>
<true/>
-
+
<key>AbandonProcessGroup</key>
<true/>
@@ -68,7 +70,7 @@
<key>PreventsSleep</key>
<true/>
-
+
<key>StandardOutPath</key>
<string>/Library/Server/Logs/caldavd.log</string>
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-07-31 21:05:16 UTC (rev 13810)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-07-31 23:22:20 UTC (rev 13811)
@@ -1130,6 +1130,10 @@
# means no automatic shutdown.
"AgentInactivityTimeoutSeconds" : 5 * 60,
+ # Program to execute if the service cannot start; for example in OS X we
+ # want to call serveradmin to disable the service so launchd does not keep
+ # respawning it. Empty string to disable this feature.
+ "ServiceDisablingProgram": "",
# These three keys are relative to ConfigRoot:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140731/dfbc5688/attachment.html>
More information about the calendarserver-changes
mailing list