Ignore:
Timestamp:
10/27/10 17:48:15 (14 years ago)
Author:
Daniela Dorner
Message:
lock in db instead of lockfile
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/datacenter/scripts/sourcefile

    r10007 r10041  
    4848   export SOURCEFILEPATH=`dirname $0`
    4949fi
    50 
    51 # possible solution for $0 problem:
    52 # ${BASH_SOURCE[0]}
    53 # but has to be checked and tested more carefully
    54 # should solve at least problem with login-shell and with source
     50if [ "$SCRIPTNAME" = "" ]
     51then
     52   SCRIPTNAME=`basename $0`
     53fi
     54
    5555source $SOURCEFILEPATH/setup.$AUTOMATIONSETUP
    5656
     
    6868         if ! [ "$processlog" = "" ]
    6969         then
    70             echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] ERROR could not make dir "$@ >> $processlog
     70            echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "$SCRIPTNAME"["$$"] ERROR could not make dir "$@ >> $processlog
    7171         else
    7272            echo "could not make dir "$@
     
    9595{
    9696   makedir $processlogpath
    97    echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] "$@ >> $processlog
     97   echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "$SCRIPTNAME"["$$"] "$@ >> $processlog
    9898}
    9999
     
    105105      printprocesslog "DEBUG " `rm -v $lockfile`
    106106   fi
    107    printprocesslog "DEBUG finished $0"
     107   printprocesslog "DEBUG finished "$SOURCEFILEPATH"/"$SCRIPTNAME
    108108   exit
    109109}
     
    153153function checklock()
    154154{
    155    if ! echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] "`uname -a` > $lockfile 2>/dev/null
     155   if ! echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "$SCRIPTNAME"["$$"] "`uname -a` > $lockfile 2>/dev/null
    156156   then
    157157      printprocesslog "WARN lockfile $lockfile exists"
     
    424424   do
    425425      query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"='${primaries[$s*${#prims[@]}+$j]}' "
    426    done   
     426   done
     427   # add additional query to allow for locking in db
     428   if [ "$1" = "start" ]
     429   then
     430      query=$query" AND ISNULL("$step"Status.fStartTime) "
     431   fi
     432   # add row count to know how many rows have been changed
     433   query=$query"; SELECT ROW_COUNT();"
    427434   # print query
    428435   printprocesslog "DEBUG setstatus for step $step QUERY: "$query
    429436   # execute query
    430    if ! mysql -s -u $us --password=$pw --host=$ho $db -e " $query "
     437   if ! numchanged=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    431438   then
    432439      printprocesslog "ERROR could not set status in db (program: $program, function setstatus)"
    433440      finish
     441   fi
     442   if [ $numchanged -gt 0 ]
     443   then
     444      printprocesslog "INFO successful setting of status in db (program: $program, function setstatus)"
     445   else
     446      printprocesslog "INFO status in db was already set by other process (program: $program, function setstatus)"
    434447   fi
    435448}
Note: See TracChangeset for help on using the changeset viewer.