[Swift-commit] r4556 - in SwiftApps/SwiftR/Swift: R exec

tga at ci.uchicago.edu tga at ci.uchicago.edu
Fri Jun 3 13:40:35 CDT 2011


Author: tga
Date: 2011-06-03 13:40:35 -0500 (Fri, 03 Jun 2011)
New Revision: 4556

Modified:
   SwiftApps/SwiftR/Swift/R/Apply.R
   SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh
   SwiftApps/SwiftR/Swift/exec/start-swift
   SwiftApps/SwiftR/Swift/exec/start-swift-daemon
Log:
No longer assumes that /tmp/$USER is writable - falls back to a random temporary directory and gives meaningful error messages when misconfigured.


Modified: SwiftApps/SwiftR/Swift/R/Apply.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/Apply.R	2011-06-03 17:32:56 UTC (rev 4555)
+++ SwiftApps/SwiftR/Swift/R/Apply.R	2011-06-03 18:40:35 UTC (rev 4556)
@@ -199,7 +199,16 @@
     requestid = getOption(".swift.requestid") + 1;
   }
   else {
-    requestdirbase = file.path(tmpdir, Sys.info()[["user"]],"SwiftR",
+    topdir <- file.path(tmpdir, Sys.info()[["user"]],"SwiftR")
+    if (!dir.create(topdir,recursive=TRUE,showWarnings=FALSE, 
+            mode=kDIR_MODE)) {
+        oldtopdir <- topdir
+        topdir <- tempdir()
+        warning(paste("Could not create working directory", oldtopdir, 
+                    "instead using", topdir))
+    }
+
+    requestdirbase = file.path(topdir, 
                 sprintf("requests.P%.5d",Sys.getpid()))
     dir.create(requestdirbase,recursive=TRUE,showWarnings=FALSE, 
             mode=kDIR_MODE)

Modified: SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh
===================================================================
--- SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh	2011-06-03 17:32:56 UTC (rev 4555)
+++ SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh	2011-06-03 18:40:35 UTC (rev 4556)
@@ -88,6 +88,19 @@
 # Ensure that the dir for this slot exists. 
 
 BASEDIR=$tmp/$(id -nu)/SwiftR/Rworkers
+if mkdir -p $BASEDIR; then
+    :
+else
+    OLD_BASEDIR=$BASEDIR
+    BASEDIR=$tmp/SwiftR.${SWIFT_WORKER_PID}.Rworkers
+    mkdir -p $BASEDIR
+    basedir_ok=$?
+    if [ $basedir_ok != 0 ]; then
+        echo "Could not create worker directory in either $OLD_BASEDIR or $BASEDIR"
+        exit 1
+    fi
+fi
+
 WORKERDIR=$BASEDIR/worker.$SWIFT_WORKER_PID
 SLOTDIR=$WORKERDIR/${SWIFT_JOB_SLOT}
 

Modified: SwiftApps/SwiftR/Swift/exec/start-swift
===================================================================
--- SwiftApps/SwiftR/Swift/exec/start-swift	2011-06-03 17:32:56 UTC (rev 4555)
+++ SwiftApps/SwiftR/Swift/exec/start-swift	2011-06-03 18:40:35 UTC (rev 4556)
@@ -42,7 +42,7 @@
 {
   get-contact
   LOGDIR=$(pwd)/swiftworkerlogs # full path. FIXME: Generate this with remote-side paths if not shared dir env?
-  LOGDIR=$tmp/$USER/SwiftR/swiftworkerlogs  # FIXME: left this in /tmp so it works on any host. Better way?
+  LOGDIR=$topdir/swiftworkerlogs  # FIXME: left this in /tmp so it works on any host. Better way?
 
   #  mkdir -p $LOGDIR # is done with the ssh command, below
 
@@ -319,7 +319,7 @@
 {
   get-contact
   LOGDIR=$(pwd)/swiftworkerlogs # full path. FIXME: Generate this with remote-side paths if not shared dir env?
-  LOGDIR=/tmp/$USER/SwiftR/swiftworkerlogs  # FIXME: left this in /tmp so it works on any host. Better way?
+  LOGDIR=$topdir/swiftworkerlogs  # FIXME: left this in /tmp so it works on any host. Better way?
 
   mkdir -p $LOGDIR
 
@@ -434,7 +434,7 @@
     argname=$1; shift
     #check if positive integer
     if [ "$1" -gt 0 ] 2> /dev/null; then
-        time_secs=$time
+        time_secs=$(( $time * 60 ))
  #       echo time_secs: $time_secs
         return 0
     fi
@@ -580,26 +580,43 @@
 source $SWIFTRBIN/compat-setup
 SWIFTBIN=$SWIFTRBIN/../swift/bin  # This depends on ~/SwiftR/Swift/swift being a symlink to swift in RLibrary/Swift
 
-rundir=$tmp/$USER/SwiftR/swift.$server  # rundir prefix # FIXME: handle multiple concurent independent swift servers per user
-mkdir -p $(dirname $rundir)
 
+
 # Setup a working directory
 if [ "$workdir" = NONE ]
 then
+    topdir=$tmp/$USER/SwiftR
+
+    if mkdir -p $topdir 2> /dev/null ; then
+        :
+    else
+        topdir=$(mktemp -d $tmp/SwiftR.XXXXXX)
+        created_ok=$?
+        if [ "$created_ok" -ne 0 ]; then
+            echo "Could not create temporary directory under $tmp"
+            exit 1
+        fi
+    fi
+
+    rundir=$topdir/swift.$server  # rundir prefix 
     doack=FALSE
-    trundir=$(mktemp -d $rundir.XXXX) # FIXME: check success
-    if [ "$?" != "0" ]
+    trundir=$(mktemp -d $rundir.XXXX) 
+    created_ok=$?
+    if [ "$created_ok" -ne 0 ]
     then
-        echo "Could not create temporary directory under $tmp/$USER/SwiftR"
+        echo "Could not create temporary directory under $topdir/SwiftR"
         exit 1
     fi
 else 
+    topdir=`dirname "$workdir"`
+    rundir=$topdir/swift.$server  # rundir prefix 
     doack=TRUE # let -daemon script know when we are done
     echo Working in $workdir
     trundir=$workdir
     mkdir -p $workdir
 fi
 
+# link temporary dir with different server name
 rm -f $rundir
 ln -s $trundir $rundir
 

Modified: SwiftApps/SwiftR/Swift/exec/start-swift-daemon
===================================================================
--- SwiftApps/SwiftR/Swift/exec/start-swift-daemon	2011-06-03 17:32:56 UTC (rev 4555)
+++ SwiftApps/SwiftR/Swift/exec/start-swift-daemon	2011-06-03 18:40:35 UTC (rev 4556)
@@ -6,20 +6,33 @@
 # This script forks off a child process, detaches it
 # and then, as the only thing written to stdout, echoes
 # the pid of start-swift
+set -x
 ssscript=`dirname $0`/start-swift
 
 # Choose a working directory
 tmp=${SWIFTR_TMP:-/tmp}
 
-mkdir -p $tmp/$USER/SwiftR
-workdir=$(mktemp -d $tmp/$USER/SwiftR/swift.XXXX) 
+topdir=$tmp/$USER/SwiftR
 
+if mkdir -p $topdir 2> /dev/null ; then
+    :
+else
+    topdir=$(mktemp -d $tmp/SwiftR.XXXXXX)
+    created_ok=$?
+    if [ $created_ok -ne 0 ]; then
+        echo "Could not create temporary directory under $tmp"
+        exit 1
+    fi
+fi
+
+workdir=$(mktemp -d $topdir/swift.XXXX) 
+
 ackfifo=$workdir/ackfifo
 mkfifo $ackfifo
 
 if [ "$?" != "0" ]
 then
-    echo "Could not create temporary directory under $tmp/$USER/SwiftR"
+    echo "Could not create temporary directory under $topdir"
     exit 1
 fi
 




More information about the Swift-commit mailing list