3e95941a47ceab73b044f8eeb6efa55d6d6bced3
[irspy-moved-to-github.git] / bin / irspy-update.sh
1 #!/bin/sh
2 # Copyright (c) 2010 Index Data, http://www.indexdata.com
3 #
4 # irspy-update.sh - wrapper for irspy.pl
5 #
6 # run irspy with a smaller set of records in a loop to avoid out-of-memory
7 #
8 # for a fast update, run this:
9 #       $ env irspy_test=Quick ./irspy-update.sh
10
11 home=/usr/local/src/git
12 cd $home/irspy/bin || exit 2
13 logdir=../log
14 lockfile=$logdir/irspy-update.lock
15
16 # run a full update by default, use Quick for a fast update
17 : ${irspy_test=Main}
18
19 mkdir -p $logdir || exit2
20
21 if [ -f $lockfile ]; then
22     pid=`cat $lockfile`
23     if kill -0 $pid 2>/dev/null; then
24         echo "This script is already running with pid: $pid"
25         exit 1
26     fi
27 fi
28 echo $$ > $lockfile || exit 2
29
30 weekday=`date '+%w'`
31 for i in 0 1 2 3 4 5 6
32 do
33    logfile=$logdir/irspy-mod-$i.log.$weekday
34    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
35
36    sleep 1 # catch ctr-c before compressing the log
37    gzip -f $logfile
38 done
39
40 rm -f $lockfile
41