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

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Feb 25 16:50:13 CST 2011


Author: tga
Date: 2011-02-25 16:50:13 -0600 (Fri, 25 Feb 2011)
New Revision: 4145

Modified:
   SwiftApps/SwiftR/Swift/R/Apply.R
   SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh
   SwiftApps/SwiftR/Swift/exec/start-swift
Log:
Finished adding in detection of when R worker process fails to start up.


Modified: SwiftApps/SwiftR/Swift/R/Apply.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/Apply.R	2011-02-25 15:45:03 UTC (rev 4144)
+++ SwiftApps/SwiftR/Swift/R/Apply.R	2011-02-25 22:50:13 UTC (rev 4145)
@@ -91,7 +91,12 @@
     
     res <- getServiceResponse(resultPipeName, timeout)
     # Check that the message was correct
-    if (res[[1]] != "done") {
+    if (substring(res[[1]], 1, 6) == "error:")  {
+      stop(paste("Received error message from Swift '", res, 
+                "'.  The swift server has shut down, rerun swiftInit to"
+                ," restart", sep=""))
+    }
+    else if (res[[1]] != "done") {
       stop(paste("Got unexpected message '", 
             paste(res, collapse="\n"),"' on fifo ",
             "aborting job", sep=""))

Modified: SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh
===================================================================
--- SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh	2011-02-25 15:45:03 UTC (rev 4144)
+++ SwiftApps/SwiftR/Swift/exec/EvalRBatchPersistent.sh	2011-02-25 22:50:13 UTC (rev 4145)
@@ -3,7 +3,6 @@
 # Arguments: inputBatchSaveFile outputBatchSaveFile
 #   bash @shellscript @RServerScript @rcall @result stdout=@stout stderr=@sterr;
 
-set -x
 
 # Set restrictive umask for duration of script
 # This value prevents any other users from reading
@@ -89,12 +88,9 @@
 
 function start_timeout {
     ppid=$$
-    echo start_timeout
     trap "timeout_handler" SIGHUP
     (
-    echo timeout_handler for $ppid sleeping
     sleep ${TIMEOUT}s
-    echo timeout_handler work up
     kill -1 $ppid  &> /dev/null #SIGHUP 
     if [ "$1" != "" ]; then
         kill -1 $1  &> /dev/null #SIGHUP 
@@ -104,7 +100,6 @@
 
 function stop_timeout {
     #DEBUG
-    echo stop_timeout
     trap "" SIGHUP
 }
 
@@ -129,10 +124,10 @@
   mkfifo $SLOTDIR/fromR.fifo
   chmod +x $RServerScript
   echo "$0: INFO: Launching $RServerScript $SLOTDIR"
-  PATH=.:$PATH
   #echo PATH: $PATH > $SLOTDIR/R.log
   #which Rscript >> $SLOTDIR/R.log
-  echo $PATH
+  
+  echo LD_LIBRARYPATH= $LD_LIBRARY_PATH
   $RServerScript $SLOTDIR >> $SLOTDIR/R.log 2>&1 &   # launch R server
   # idletimer $SLOTDIR </dev/null >/dev/null 2>&1 & # R saves pid in R.pid for idletimer to kill it
   echo "$0: INFO: Launched $RServerScript $SLOTDIR Rscript"
@@ -162,7 +157,6 @@
 
 echo run $(pwd)/$callFile $(pwd)/$resultFile > $SLOTDIR/toR.fifo &
 echopid=$!
-echo echopid $echopid
 start_timeout $echopid
 
 if wait $echopid

Modified: SwiftApps/SwiftR/Swift/exec/start-swift
===================================================================
--- SwiftApps/SwiftR/Swift/exec/start-swift	2011-02-25 15:45:03 UTC (rev 4144)
+++ SwiftApps/SwiftR/Swift/exec/start-swift	2011-02-25 22:50:13 UTC (rev 4145)
@@ -558,14 +558,15 @@
     # Find and terminate R workers: they should register their PiD
     # in a standard location based on the pid of this start-swift
     # script
-    if [ "$keepdir" = "FALSE" ]
-    then
-        for rwork in `(shopt -s nullglob; echo ../Rworkers/worker.$$/*/)`
-        do
+    for rwork in `(shopt -s nullglob; echo ../Rworkers/worker.$$/*/)`
+    do
+        if [ -f "$rwork/R.pid" ]; then
             kill `cat $rwork/R.pid` &> /dev/null
+        fi
+        if [ "$keepdir" = "FALSE" ]; then
             rm -rf $rwork
-        done
-    fi
+        fi
+    done
     stdcleanup_end
     exit 0
   }
@@ -659,5 +660,12 @@
 fi
 
 $SWIFTRBIN/../swift/bin/swift $swiftLoggingFlag -config cf -tc.file tc -sites.file sites.xml $script -pipedir=$(pwd) >& $out </dev/null
+exitcode=$?
+# Do any cleanup if swift exits in this manner
+if [ "$exitcode" != 0 ]; then
+    echo "error: Swift exited unexpectedly with $exitcode" > resultpipe &
+    echopid=$!
+    sleep 5
+    kill $echopid &> /dev/null
+fi
 
-# Do any cleanup if swift exits in this manner




More information about the Swift-commit mailing list