727a2656b20f4533a6aff45bd6089b34559beb27
[irspy-moved-to-github.git] / bin / irspy-update.sh
1 #!/bin/sh
2 #
3 # wrapper for irspy.pl
4 #
5 # run irspy with a smaller set of records in a loop to avoid out-of-memory
6 #
7 # for a fast update, run this:
8 #       $ env irspy_test=Quick ./irspy-update.sh
9
10 home=/usr/local/src/git
11 cd $home/irspy/bin || exit 2
12 logdir=../log
13 lockfile=$logdir/irspy-update.lock
14
15 # run a full update by default, use Quick for a fast update
16 : ${irspy_test=Main}
17
18 mkdir -p $logdir || exit2
19
20 if [ -f $lockfile ]; then
21     pid=`cat $lockfile`
22     if kill -0 $pid 2>/dev/null; then
23         echo "This script is already running with pid: $pid"
24         exit 1
25     fi
26 fi
27 echo $$ > $lockfile || exit 2
28
29 weekday=`date '+%w'`
30 for i in 0 1 2 3 4 5 6
31 do
32    logfile=$logdir/irspy-mod-$i.log.$weekday
33    YAZ_LOG=irspy,irspy_test,irspy_task nice -10 time perl -I../lib irspy.pl -n 50 -d -M 3500 -f'cql.allRecords=1 not zeerex.disabled = 1' -t $irspy_test -m 7,$i localhost:8018/IR-Explain---1 > $logfile 2>&1
34
35    sleep 1 # catch ctr-c before compressing the log
36    gzip -f $logfile
37 done
38
39 rm -f $lockfile
40