Ignore:
Timestamp:
10/27/10 17:48:15 (14 years ago)
Author:
Daniela Dorner
Message:
lock in db instead of lockfile
Location:
trunk/Mars/datacenter/scripts
Files:
5 edited

Legend:

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

    r9920 r10041  
    3737
    3838# get sequence #
    39 gettodo "1"
    40 sequence=${primaries[0]}
    41 cereskey=${primaries[1]}
    42 
    43 # lock sequ for cal
    44 lockfile=$lockpath/lock-$step-$sequence-$cereskey.txt
    45 checklock
     39numchanged=0
     40while (( 0 < 21 ))
     41do
     42   if ! [ $numchanged -eq 1 ]
     43   then
     44      if ! [ "$sequence" = "" ] && ! [ "$cereskey" = "" ]
     45      then
     46         printprocesslog "INFO $program for sequence $sequence cereskey $cereskey is already running => request new number "
     47      fi
     48      gettodo "1"
     49      sequence=${primaries[0]}
     50      cereskey=${primaries[1]}
     51      if [ "$sequence" = "" ] || [ "$cereskey" = "" ]
     52      then
     53         printprocesslog "INFO nothing to do for $program "
     54      fi
     55   else
     56      printprocesslog "INFO starting $program for sequence $sequence cereskey $cereskey"
     57      break
     58   fi
     59   setstatus "start"
     60done
    4661
    4762cd $mars
    4863
    4964# run calibration for sequence
    50 printprocesslog "INFO starting $program for sequence $sequence cereskey $cereskey"
    5165
    5266# define files and paths
     
    5771callistorc=$setuppath/$program/`printf %03d $cereskey`/callisto.rc
    5872inpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $sequence | cut -c 1-4`/`printf %08d $sequence | cut -c 5-8`
    59 
    60 setstatus "start"
    6173
    6274command="./callisto -b -q -v4 -f --out=$outpath --ind=$inpath --log=$log.log --html=$log.html --config=$callistorc $sequfile"
  • trunk/Mars/datacenter/scripts/runceres

    r9919 r10041  
    3737set -C
    3838
    39 # get sequence #
    40 gettodo "1"
    41 run=${primaries[0]}
    42 cereskey=${primaries[1]}
    43 
    44 # lock sequ for cal
    45 lockfile=$lockpath/lock-$step-$run.$cereskey.txt
    46 checklock
     39# get run #
     40numchanged=0
     41while (( 0 < 21 ))
     42do
     43   if ! [ $numchanged -eq 1 ]
     44   then
     45      if ! [ "$run" = "" ] && ! [ "$cereskey" = "" ]
     46      then
     47         printprocesslog "INFO $program for run $run cereskey $cereskey is already running => request new number "
     48      fi
     49      gettodo "1"
     50      run=${primaries[0]}
     51      cereskey=${primaries[1]}
     52      if [ "$run" = "" ] || [ "$cereskey" = "" ]
     53      then
     54         printprocesslog "INFO nothing to do for $program "
     55      fi
     56   else
     57      printprocesslog "INFO starting $program for run $run cereskey $cereskey"
     58      break
     59   fi
     60   setstatus "start"
     61done
    4762
    4863cd $mars
    4964
    50 # run calibration for sequence
    51 printprocesslog "INFO starting $program for run $run and ceres-setup $cereskey"
    52 
    53 setstatus "start"
     65# run ceres for run
    5466
    5567setupfile=$setuppath/$program/`printf %03d $cereskey`/ceres.rc
  • trunk/Mars/datacenter/scripts/runcorsika

    r10006 r10041  
    144144
    145145
    146 # get sequence #
    147 gettodo "1"
    148 run=${primaries[0]}
    149 file=${primaries[1]}
    150 
    151 # lock sequ
    152 lockfile=$lockpath/lock-$step-$run.$file.txt
    153 checklock
    154 
    155 printprocesslog "INFO starting $program for run $run and file $file"
    156 
    157 setstatus "start"
    158 
     146# get run # and file #
     147numchanged=0
     148while (( 0 < 21 ))
     149do
     150   if ! [ $numchanged -eq 1 ]
     151   then
     152      if ! [ "$run" = "" ] && ! [ "$file" = "" ]
     153      then
     154         printprocesslog "INFO $program for run $run and file $file is already running => request new number "
     155      fi
     156      gettodo "1"
     157      run=${primaries[0]}
     158      file=${primaries[1]}
     159      if [ "$run" = "" ] || [ "$file" = "" ]
     160      then
     161         printprocesslog "INFO nothing to do for $program "
     162      fi
     163   else
     164      printprocesslog "INFO starting $program for run $run and file $file"
     165      break
     166   fi
     167   setstatus "start"
     168done
     169
     170# running corsika
    159171printprocesslog "INFO run $program for run $run  and file $file"
    160172printprocesslog "INFO create input card for run $run  and file $file"
  • trunk/Mars/datacenter/scripts/runstar_mc

    r9611 r10041  
    3636
    3737# get sequence #
    38 gettodo "1"
    39 sequence=${primaries[0]}
    40 cereskey=${primaries[1]}
    41 
    42 # lock sequ for cal
    43 lockfile=$lockpath/lock-$step-$sequence-$cereskey.txt
    44 checklock
     38numchanged=0
     39while (( 0 < 21 ))
     40do
     41   if ! [ $numchanged -eq 1 ]
     42   then
     43      if ! [ "$sequence" = "" ] && ! [ "$cereskey" = "" ]
     44      then
     45         printprocesslog "INFO $program for sequence $sequence cereskey $cereskey is already running => request new number "
     46      fi
     47      gettodo "1"
     48      sequence=${primaries[0]}
     49      cereskey=${primaries[1]}
     50      if [ "$sequence" = "" ] || [ "$cereskey" = "" ]
     51      then
     52         printprocesslog "INFO nothing to do for $program "
     53      fi
     54   else
     55      printprocesslog "INFO starting $program for sequence $sequence cereskey $cereskey"
     56      break
     57   fi
     58   setstatus "start"
     59done
    4560
    4661cd $mars
    4762
    4863# run calibration for sequence
    49 printprocesslog "INFO starting $program for sequence $sequence cereskey $cereskey"
    5064
    5165# define files and paths
     
    5569log=$outpath/$program`printf %08d $sequence`
    5670inpath=$mcpath/callisto/`printf %03d $cereskey`/`printf %08d $sequence | cut -c 1-4`/`printf %08d $sequence | cut -c 5-8`
    57 
    58 setstatus "start"
    5971
    6072command="./star -b -q -v4 -f --ind=$inpath --out=$outpath --log=$log.log --html=$log.html $sequfile"
  • 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.