Project

General

Profile

« Previous | Next » 

Revision 7085

inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub.make: Added option to wait for new rows, in the same way tnrs_db does

View differences:

inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub.make
1 1
#!/bin/bash
2 2
# Adds scrubbed taxondeterminations to VegBIEN
3
# Usage: make inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub-remake
3
# Usage: make inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub-remake [wait=1]
4 4

  
5 5
selfDir="$(dirname -- "$0")"
6 6
selfDirName="$(basename -- "$selfDir")"
7 7

  
8
# Config
9
let pause=2*60*60 # sec; = 2 hr
10
let maxPause=9*60*60 # sec; =9 hr; must be >= max partition import time (1.5 hr)
11
test "$pause" -le "$maxPause" || exit -1
12

  
8 13
cd "$selfDir/.." # needed by make
9 14

  
10 15
make () { env make --makefile=../input.Makefile "$@"; }
......
18 23
        >/dev/null
19 24
}
20 25

  
26
let totalPause=0
21 27
while true; do
22 28
    make "$selfDirName"/import
23 29
    
24
    # Stop if no new rows added
25
    rowsAdded || break
30
    if ! rowsAdded; then
31
        test -n "$wait" || break
32
        echo "Waited $totalPause sec total"
33
        let 'totalPause += pause'
34
        test "$totalPause" -gt "$maxPause" && break
35
        echo "Waiting $pause sec..."
36
        sleep "$pause" # wait for more rows
37
        continue # try again
38
    fi
39
    # otherwise, rows found
40
    let totalPause=0
26 41
done

Also available in: Unified diff