forked from andrewjpage/crawl2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrawl
executable file
·89 lines (71 loc) · 2.14 KB
/
crawl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
start_time=$(date +%s)
SCRIPT_DIRECTORY=`dirname $0`
hput() {
eval "$1""$2"='$3'
}
hget() {
eval echo '${'"$1$2"'#hash}'
}
hput COMMANDS chado2es org.genedb.crawl.elasticsearch.index.sql.IncrementalSQLIndexBuilder
hput COMMANDS das2es org.genedb.crawl.elasticsearch.index.das.DASIndexBuilder
hput COMMANDS das2file org.genedb.crawl.elasticsearch.index.das.DASFileBuilder
hput COMMANDS gff2es org.genedb.crawl.elasticsearch.index.gff.GFFIndexBuilder
hput COMMANDS org2es org.genedb.crawl.elasticsearch.index.json.OrganismIndexBuilder
hput COMMANDS ref2es org.genedb.crawl.elasticsearch.index.json.ReferenceIndexBuilder
hput COMMANDS cv2es org.genedb.crawl.elasticsearch.index.cv.CvIndexBuilder
hput COMMANDS hazelcast org.genedb.crawl.hazelcast.HazelcastService
usage() {
usage_string="crawl ["
sep=""
for i in $(compgen -A variable COMMANDS);
do
key=${i/COMMANDS/}
usage_string=$usage_string$sep$key
sep="|"
done
usage_string=$usage_string"] [OPTIONS]"
echo $usage_string
exit 1
}
# this is the classpath location in the project folder
CP1="$SCRIPT_DIRECTORY/build/libs/"
# this is the expected classpath location in an installed folder
CP2="$SCRIPT_DIRECTORY/../lib/"
if [[ -z $CRAWL_CLASSPATH ]]
then
if [ -d $CP1 ]; then
export CRAWL_CLASSPATH="$CP1/*"
elif [ -d "$CP2" ]; then
export CRAWL_CLASSPATH="$CP2/*"
else
echo "Could not find a crawl library in $CP1 or $CP1, and no CRAWL_CLASSPATH has been set. Aborting."
fi
fi
if [[ -z $CRAWL_JAVA_SETTINGS ]]
then
export CRAWL_JAVA_SETTINGS="-Xmx2000m"
fi
if [ $# -lt 1 ]; then
usage
fi
COMMAND=$1
shift
JAVA_ENTRY_POINT=`hget COMMANDS $COMMAND`
if [[ ${#JAVA_ENTRY_POINT} -lt 1 ]]
then
usage
fi
if [[ -z $JAVA_HOME ]]
then
export JAVA='java'
else
export JAVA="$JAVA_HOME/bin/java"
fi
# echo $JAVA
# the java.net.preferIPv4Stack must be set to true, or else Hazelcast
# instances may not be able to see it (it is also set in the Hazelcast
# example wrapper scripts)
$JAVA $CRAWL_JAVA_SETTINGS -Djava.net.preferIPv4Stack=true -cp "$CRAWL_CLASSPATH" $JAVA_ENTRY_POINT "$@"
finish_time=$(date +%s)
echo "Time duration: $((finish_time - start_time)) secs."