-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcloud_start.sh
executable file
·115 lines (103 loc) · 3.77 KB
/
cloud_start.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
#
# Starts a specific SolrCloud
#
# TODO: Increase 5 second timeout on shutdown to avoid stale write.lock
#
###############################################################################
# CONFIG
###############################################################################
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Local overrides
fi
pushd ${BASH_SOURCE%/*} > /dev/null
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Project overrides
fi
source general.conf
: ${CLOUD:=`pwd`/cloud}
: ${RETRIES:=6} # default number of retries on start probe before giving up
: ${AUTO_INSTALL:=false}
popd > /dev/null
usage() {
echo "Usage: ./cloud_start.sh <`echo \"$VERSIONS\" | sed 's/ / | /g'`>"
echo ""
echo "Installed SolrClouds: `ls ${CLOUD} | tr '\n' ' '`"
exit $1
}
check_parameters() {
if [[ -z "$1" && -z "$VERSION" ]]; then
echo "No Solr version specified."$'\n'
usage
elif [[ ! -z "$1" ]]; then
VERSION="$1"
fi
if [ "." == ".`echo \" $VERSIONS \" | grep \" $VERSION \"`" ]; then
>&2 echo "The Solr version $VERSION is unsupported"
usage 1
fi
if [ ! -d ${CLOUD}/$VERSION ]; then
if [[ "true" != "$AUTO_INSTALL" ]]; then
>&2 echo "Error: No Solr installed at ${CLOUD}/$VERSION"
usage 5
fi
echo "Attempting install of missing SolrCloud version $VERSION"
./cloud_install.sh $VERSION
if [ ! -d ${CLOUD}/$VERSION ]; then
>&2 echo "Unable to install Solr version $VERSION"
>&2 echo "Please run ./cloud_install.sh $VERSION manually and inspect the errors"
exit 3
else
echo "Successfully installed SolrCloud $VERSION"
fi
fi
}
################################################################################
# FUNCTIONS
################################################################################
start_zoo() {
for Z in `seq 1 $ZOOS`; do
if [ ! -d zoo$Z ]; then
>&2 echo "Expected a ZooKeeper-instalation at `pwd`/zoo$S but found none."
>&2 echo "Please run ./cloud_install.sh $VERSION"
continue
fi
echo "calling> zoo$Z/bin/zkServer.sh start"
zoo$Z/bin/zkServer.sh start
done
}
start_solr() {
if [ ! "." == ".`echo \" $LAYOUT2_VERSIONS \" | grep \" $VERSION \"`" ]; then
SOLR_HOME_SUB=server/solr/
else
SOLR_HOME_SUB=example/solr/
fi
SOLR_PORT=$SOLR_BASE_PORT
for S in `seq 1 $SOLRS`; do
if [ ! -d solr$S ]; then
>&2 echo "Expected a Solr-instalation at `pwd`/solr$S but found none."
>&2 echo "Please run ./cloud_install.sh $VERSION"
continue
fi
sed -i "s/loops -lt [0-9]\+ /loops -lt $RETRIES /" $(pwd)/solr$S/bin/solr
SOLR_START_COMMAND="`pwd`/solr$S/bin/solr -m $SOLR_MEM -cloud -s `pwd`/solr$S/$SOLR_HOME_SUB -p $SOLR_PORT -z $HOST:$ZOO_BASE_PORT -h $HOST"
echo "calling> $SOLR_START_COMMAND"
LOCAL_SHOME=`pwd`/solr$S/$SOLR_HOME_SUB
SOLR_START_RESULT=`solr$S/bin/solr -m $SOLR_MEM -cloud -s $LOCAL_SHOME -p $SOLR_PORT -z $HOST:$ZOO_BASE_PORT -h $HOST`
if [ "." == ".`echo \"$SOLR_START_RESULT\" | grep \"Started Solr server\"`" ]; then
>&2 echo "Error: Unable to start Solr server using command"
>&2 echo "$SOLR_START_COMMAND"
>&2 echo "$SOLR_START_RESULT"
fi
SOLR_PORT=$(( SOLR_PORT + 10 ))
done
}
###############################################################################
# CODE
###############################################################################
check_parameters "$@"
echo "Starting ZooKeepers and Solrs in ${CLOUD}/$VERSION"
pushd ${CLOUD}/$VERSION > /dev/null
start_zoo
start_solr
popd > /dev/null