Revision
1515
Author
wsanchez@apple.com
Date
2007-05-07 16:14:13 -0700 (Mon, 07 May 2007)

Log Message

On Mac OS X, deamonizing doesn't appear to connect the process to the
correct Mach bootstrap port, so if you start the server and then exit
your shell, the server fails to do things that require Mach ports
(eg. OpenDirectory calls).

Workaround is to launch the server via launchctl such that launchd
hooks us up.

Modified Paths

Diff

Modified: CalendarServer/trunk/run (1514 => 1515)


--- CalendarServer/trunk/run	2007-05-07 23:10:18 UTC (rev 1514)
+++ CalendarServer/trunk/run	2007-05-07 23:14:13 UTC (rev 1515)
@@ -144,6 +144,14 @@
   caldav="${wd}";
 fi;
 
+if [ -z "${caldavd_wrapper_command:-}" ]; then
+  if [ "$(uname -s)" == "Darwin" ]; then
+      caldavd_wrapper_command="launchctl bsexec /";
+  else
+      caldavd_wrapper_command="";
+  fi;
+fi;
+
     top="$(cd "${caldav}/.." && pwd -L)"
 patches="${caldav}/lib-patches";
 twisted="${top}/Twisted";
@@ -230,11 +238,12 @@
     if [ ! -d "${wd}/logs" ]; then
       mkdir "${wd}/logs";
     fi;
-    exec "${caldav}/bin/caldavd" ${daemonize} \
-        -f "${config}"                        \
-        -T "${twisted}/bin/twistd"            \
-        -P "${plugin_name}"                   \
-        -t "${service_type}"                  \
+    exec ${caldavd_wrapper_command}          \
+        "${caldav}/bin/caldavd" ${daemonize} \
+        -f "${config}"                       \
+        -T "${twisted}/bin/twistd"           \
+        -P "${plugin_name}"                  \
+        -t "${service_type}"                 \
         ${profile};
     cd /;
   fi;