|
2 | 2 |
|
3 | 3 | set -e
|
4 | 4 |
|
5 |
| -SOLR_VERSION=6.6.6 |
| 5 | +SOLR_VERSION=6.6.4 |
| 6 | +SOLR_DIR=solr |
6 | 7 |
|
7 |
| -if [ -z "${BACKGROUND_SOLR}" ]; then |
8 |
| - ARGS="" |
9 |
| -else |
10 |
| - ARGS="-d" |
| 8 | + |
| 9 | +SOLR_PORT=9001 |
| 10 | + |
| 11 | +cd $(dirname $0) |
| 12 | + |
| 13 | +export TEST_ROOT=$(pwd) |
| 14 | + |
| 15 | +export SOLR_ARCHIVE="${SOLR_VERSION}.tgz" |
| 16 | + |
| 17 | +if [ -d "${HOME}/download-cache/" ]; then |
| 18 | + export SOLR_ARCHIVE="${HOME}/download-cache/${SOLR_ARCHIVE}" |
| 19 | +fi |
| 20 | + |
| 21 | +if [ -f ${SOLR_ARCHIVE} ]; then |
| 22 | + # If the tarball doesn't extract cleanly, remove it so it'll download again: |
| 23 | + tar -tf ${SOLR_ARCHIVE} > /dev/null || rm ${SOLR_ARCHIVE} |
11 | 24 | fi
|
12 | 25 |
|
13 |
| -# https://stackoverflow.com/a/246128/540644 |
14 |
| -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 26 | +if [ ! -f ${SOLR_ARCHIVE} ]; then |
| 27 | + SOLR_DOWNLOAD_URL=$(python get-solr-download-url.py $SOLR_VERSION) |
| 28 | + curl -Lo $SOLR_ARCHIVE ${SOLR_DOWNLOAD_URL} || (echo "Unable to download ${SOLR_DOWNLOAD_URL}"; exit 2) |
| 29 | +fi |
| 30 | + |
| 31 | +echo "Extracting Solr ${SOLR_ARCHIVE} to ${TEST_ROOT}/${SOLR_DIR}" |
| 32 | +rm -rf ${SOLR_DIR} |
| 33 | +mkdir ${SOLR_DIR} |
| 34 | +FULL_SOLR_DIR=$(readlink -f ./${SOLR_DIR}) |
| 35 | +tar -C ${SOLR_DIR} -xf ${SOLR_ARCHIVE} --strip-components=1 |
| 36 | + |
| 37 | +# These tuning options will break on Java 10 and for testing we don't care about |
| 38 | +# production server optimizations: |
| 39 | +export GC_LOG_OPTS="" |
| 40 | +export GC_TUNE="" |
15 | 41 |
|
16 |
| -docker run --rm ${ARGS} -p 9001:8983 \ |
17 |
| - -v $DIR/solr-setup.sh:/solr-setup.sh \ |
18 |
| - -v $DIR/confdir:/confdir:ro \ |
19 |
| - --name haystack_solr solr:${SOLR_VERSION}-slim bash -c "/solr-setup.sh" |
| 42 | +export SOLR_LOGS_DIR="${FULL_SOLR_DIR}/logs" |
| 43 | + |
| 44 | +install -d ${SOLR_LOGS_DIR} |
| 45 | + |
| 46 | +echo "Changing into ${FULL_SOLR_DIR} " |
| 47 | + |
| 48 | +cd ${FULL_SOLR_DIR} |
| 49 | + |
| 50 | +echo "Creating Solr Core" |
| 51 | +./bin/solr start -p ${SOLR_PORT} |
| 52 | +./bin/solr create -c collection1 -p ${SOLR_PORT} -n basic_config |
| 53 | +./bin/solr create -c mgmnt -p ${SOLR_PORT} |
| 54 | + |
| 55 | +echo "Solr system information:" |
| 56 | +curl --fail --silent 'http://localhost:9001/solr/admin/info/system?wt=json&indent=on' | python -m json.tool |
| 57 | +./bin/solr stop -p ${SOLR_PORT} |
| 58 | + |
| 59 | +CONF_DIR=${TEST_ROOT}/confdir |
| 60 | +CORE_DIR=${FULL_SOLR_DIR}/server/solr/collection1 |
| 61 | +mv ${CORE_DIR}/conf/managed-schema ${CORE_DIR}/conf/managed-schema.old |
| 62 | +cp ${CONF_DIR}/* ${CORE_DIR}/conf/ |
| 63 | + |
| 64 | +echo 'Starting server' |
| 65 | +cd server |
| 66 | +# We use exec to allow process monitors to correctly kill the |
| 67 | +# actual Java process rather than this launcher script: |
| 68 | +export CMD="java -Djetty.port=${SOLR_PORT} -Djava.awt.headless=true -Dapple.awt.UIElement=true -jar start.jar --module=http -Dsolr.install.dir=${FULL_SOLR_DIR} -Dsolr.log.dir=${SOLR_LOGS_DIR}" |
| 69 | + |
| 70 | +if [ -z "${BACKGROUND_SOLR}" ]; then |
| 71 | + exec $CMD |
| 72 | +else |
| 73 | + exec $CMD >/dev/null & |
| 74 | +fi |
0 commit comments