diff --git a/datamover/dist/datamover.start b/datamover/dist/datamover.start index 19a6b0c2cef51edb42fbf0cb74448e807979d299..a75b254e85690c49b0625b61e0bf06c784e9514d 100755 --- a/datamover/dist/datamover.start +++ b/datamover/dist/datamover.start @@ -1,53 +1,9 @@ #! /bin/sh - -awkBin() -{ - # We need a awk that accepts variable assignments with '-v' - case `uname -s` in - "SunOS") - echo "nawk" - return - ;; - esac - # default - echo "awk" -} - -isPIDRunning() -{ - if [ "$1" = "" ]; then - return 0 - fi - # This will have a return value of 0 on BSDish systems - isBSD="`ps aux > /dev/null 2>&1; echo $?`" - AWK=`awkBin` - if [ "$isBSD" = "0" ]; then - if [ "`ps aux | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then - return 0 - else - return 1 - fi - else - if [ "`ps -ef | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then - return 0 - else - return 1 - fi - fi -} - -if [ -f datamover.pid ]; then - PID=`cat datamover.pid` - isPIDRunning $PID - if [ $? -eq 0 ]; then - kill $PID - echo "Already running - killing PID $PID and restarting" - fi - rm datamover.pid -fi +./datamover.stop if [ "$JAVA_HOME" != "" ]; then JAVA_HOME="$JAVA_HOME/bin/" fi ${JAVA_HOME}java -jar lib/datamover.jar "$@" & echo $! > datamover.pid +echo Datamover successfuly started in the background. \ No newline at end of file diff --git a/datamover/dist/datamover.stop b/datamover/dist/datamover.stop index 5f8acb10f1b55ea10507e2a20cf86d9879adb609..2ae61f3bec2363409eff29b1e2ec6a0c0af7d774 100755 --- a/datamover/dist/datamover.stop +++ b/datamover/dist/datamover.stop @@ -1,15 +1,47 @@ #! /bin/sh +awkBin() +{ + # We need a awk that accepts variable assignments with '-v' + case `uname -s` in + "SunOS") + echo "nawk" + return + ;; + esac + # default + echo "awk" +} + +isPIDRunning() +{ + if [ "$1" = "" ]; then + return 0 + fi + # This will have a return value of 0 on BSDish systems + isBSD="`ps aux > /dev/null 2>&1; echo $?`" + AWK=`awkBin` + if [ "$isBSD" = "0" ]; then + if [ "`ps aux | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then + return 0 + else + return 1 + fi + else + if [ "`ps -ef | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then + return 0 + else + return 1 + fi + fi +} + if [ -f datamover.pid ]; then PID=`cat datamover.pid` - if [ `ps -ef |grep $PID |grep -v grep|wc -l` = 0 ] ; then - echo "Program (PID $PID) does not seem to run." - rm datamover.pid - exit 1 + isPIDRunning $PID + if [ $? -eq 0 ]; then + kill $PID + echo "Previously running program with PID $PID was found and killed" fi - kill `cat datamover.pid` rm datamover.pid - echo "Killed PID $PID..." -else - echo "No datamover.pid found." fi