Ignore:
Timestamp:
08/04/08 13:41:17 (16 years ago)
Author:
snruegam
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/cutslices

    r9046 r9081  
    2020#   Author(s): Stefan Ruegamer 12/2007 <mailto:snruegam@astro.uni-wuerzburg.de>
    2121#
    22 #   Copyright: MAGIC Software Development, 2000-2007
     22#   Copyright: MAGIC Software Development, 2000-2008
    2323#
    2424#
     
    3232source `dirname $0`/sourcefile
    3333printprocesslog "INFO starting $0"
    34 echo "This script has not been adapted to the new file structure (MAGIC II). "
    35 echo "Please adapt it before using it."
    36 exit
    37 
    3834program=compmux
    3935column=fCompmux
     
    4137set -C
    4238
    43 scriptlog=/magic/datacenter/compmux/$program-$datetime.log
     39scriptlog=$runlogpath/run$program-$datetime.log
    4440date >> $scriptlog 2>&1
    45 todofile=$listpath/ToDo-$table-$column.txt
    4641
    47 if [ -e $todofile ]
    48 then
    49    echo "$program is already running -> exit" >> $scriptlog 2>&1
    50    exit
    51 fi
    52 
    53 #get todo list
    54 getdolist >> $scriptlog 2>&1
    55 
    56 #retrieving runs from todo file
    57 files=(`cat $listpath/ToDo-$table-$column.txt`)
    58 if [ "$files" = "" ]
    59 then
    60    echo "nothing to do -> exit" >> $scriptlog 2>&1
    61    finish >> $scriptlog 2>&1
    62 fi
    63 
    64 for file in ${files[@]}
     42# query db 20 times for jobs
     43for ((j=0 ; j < 20 ; j++))
    6544do
    66    echo -e "\ngetting path for run $file..." >> $scriptlog 2>&1
    67    fullpath=`find $datapath/rawfiles/2007/0[2-9] -name *${file}_[DCPS]_*`
     45   gettodo "1" >> $scriptlog 2>&1
     46   runno=${primaries[0]}
     47   tempfile=/data/tmp/temp${runno}.gz
    6848   
    69    lockfile=$lockpath/lock-$program-$file.txt
     49   lockfile=$lockpath/lock-$table-$column-$runno.txt
     50   checklock >> $scriptlog 2>&1
    7051   
    71    #check lock file and stop for this run if already being processed
    72    checklock continue >> $scriptlog 2>&1
    73    
    74    primvar=$file
    7552   setstatus "start" >> $scriptlog 2>&1
    7653   
    77    cd $mars
     54   # try to find the file; if impossible, continue with an error
     55   echo "getting path for run $runno..." >> $scriptlog 2>&1
     56   printprocesslog "INFO starting $program for run $runno"
     57   fullname=`find $datapath/rawfiles/2007/0[2-9] -name 20070*${runno}_[DCPS]_*.raw.gz`
     58   arraycheck=`echo $fullname | wc -w`
     59   if [ "$fullname" == "" ] || ! [ $arraycheck == 1 ]
     60   then
     61      echo "ERROR file for run $runno not found or more than one file found... continue" >> $scriptlog 2>&1
     62      printprocesslog "ERROR $program failed, file for run $runno not found or more than one file found"
     63      rm -v $lockpath/lock-$table-$column-$runno.txt >> $scriptlog 2>&1
     64      check=20
     65      com=$FCompmux
     66      setstatus "stop" >> $scriptlog 2>&1
     67      echo "" >> $scriptlog 2>&1
     68      continue
     69   fi
    7870   
    79    #cut the slices
    80    gzip -cd $fullpath | $mars/datacenter/compmux | gzip -1c > /tmp/temp${file}.gz
    81    check1=$?
    82    touch -r $fullpath /tmp/temp${file}.gz
     71   # cut the slices
     72   check1=`ssh -nx phoenix 'cd /home/operator/compmux ; nice -n 19 gzip -cd' $fullname '| nice -n 19 ./compmux | nice -n 19 gzip -1c > /data/tmp/temp'${runno}.gz ' ; echo ${PIPESTATUS[1]}'`
    8373   
    84    #check success and insert information into the database
     74   # check success and insert information into the database
    8575   case $check1 in
    86       0)   echo " check1=$check1 -> everything ok -> compmux succeeded, overwriting old file for run $file" >> $scriptlog 2>&1
    87            mv -f /tmp/temp${file}.gz $fullpath >> $scriptlog 2>&1
     76      0)   echo " check1=$check1 -> everything ok -> compmux succeeded, overwriting old file for run $runno" >> $scriptlog 2>&1
     77           ssh -nx phoenix nice -n 19 touch -r $fullname $tempfile
     78           ssh -nx phoenix nice -n 19 mv -f $tempfile $fullname >> $scriptlog 2>&1
    8879           check2=$?
    89            chmod a=r $fullpath
    9080           case $check2 in
    91               0)   echo " check2=$check2 -> everything ok -> mv done, setting db status for run $file" >> $scriptlog 2>&1
    92                    rm -v $lockfile >> $scriptlog 2>&1
     81              0)   echo " check2=$check2 -> everything ok -> mv done, setting db status for run $runno" >> $scriptlog 2>&1
     82                   ssh -nx phoenix nice -n 19 chmod a=r $fullname
    9383                   ;;
    94               *)   echo " check2=$check2 -> ERROR - moving of run $file failed -> continue" >> $scriptlog 2>&1
    95                    continue
     84              *)   echo " check2=$check2 -> ERROR - moving of run $runno failed" >> $scriptlog 2>&1
     85                   printprocesslog "ERROR $program failed, moving of run $runno failed"
     86                   check=$check2
     87                   com=$FCompmux
    9688                   ;;
    9789           esac
     90           printprocesslog "INFO $program finished successfully for run $runno"
    9891           ;;
    99       *)   echo " check1=$check1 -> ERROR - $program failed for run $file" >> $scriptlog 2>&1
    100            com=$FCompmux
     92      *)   echo " check1=$check1 -> ERROR - $program failed for run $runno" >> $scriptlog 2>&1
     93           printprocesslog "ERROR $program failed for run $runno"
     94           rm -v $tempfile >> $scriptlog 2>&1
    10195           check=$check1
     96           com=$FCompmux
    10297           ;;
    10398   esac
    10499   
     100   rm -v $lockpath/lock-$table-$column-$runno.txt >> $scriptlog 2>&1
    105101   setstatus "stop" >> $scriptlog 2>&1
     102   echo "" >> $scriptlog 2>&1
    106103done
     104
     105finish >> $scriptlog 2>&1
Note: See TracChangeset for help on using the changeset viewer.