X-Git-Url: http://git.indexdata.com/?p=lui-solr.git;a=blobdiff_plain;f=scripts%2Fzookeeper.sh;h=50491e45d21c8fc064fc779b35d8af2d226879a1;hp=8ff8bb4804b39b000dc4cbca7f610713be11970a;hb=a8c09bd06a96955482866a6790ab856a4ff22f63;hpb=8373b5d73c5a09872b07edb5c23b76a7f07fd055 diff --git a/scripts/zookeeper.sh b/scripts/zookeeper.sh index 8ff8bb4..50491e4 100755 --- a/scripts/zookeeper.sh +++ b/scripts/zookeeper.sh @@ -1,28 +1,64 @@ -#/bin/bash +#!/bin/bash -DIR=`dirname $0` -PROG=`basename $0` +NAME="indexdata-lui-solr-zookeeper" +HOST=localhost +PORT=8983 +SHARDS=2 +PID_FILE=/var/run/${NAME}.pid +LOG_FILE=/var/log/${NAME}.log +ZOOKEEPER=yes +OPTIONS=${OPTIONS:-options} -cd $DIR -OPTIONS="-Djetty.port=7500 -DzkHost=opencontent-solr.index:9983" -if [ -f "options" ]; then - source options +if [ -f "$OPTIONS" ]; then + source $OPTIONS else - echo "No options file. Using defaults: $OPTIONS" + echo "No options file ($OPTIONS). Using defaults." +fi +let ZKPORT=$PORT+1000 +if [ "$ZKHOSTS" == "" ] ; then + ZKHOSTS=${HOST}:${ZKPORT} +fi + +if [ "$BOOTSTRAP_CONF" != "" ] ; then + BOOTSTRAP_OPT="-Dbootstrap_confdir=$BOOTSTRAP_CONF" +fi +if [ "$PORT" == "" ] ; then + echo Port missing + +fi +if [ "$ZKHOSTS" == "" ] ; then + echo ZKHOSTS missing +fi +if [ "$SHARDS" == "" ] ; then + echo SHARDS missing +fi +if [ "$ZOOKEEPER" == "yes" ] ; then + ZKRUN="-DzkRun -DnumShards=${SHARDS}" +fi +if [ "${SOLR_HOME}" != "" ] ; then + SOLR_HOME_OPT="-Dsolr.solr.home=${SOLR_HOME}" fi -if [ "$1" = "start" ]; then - if [ -f "${PROG}.pid" ] ; then - echo "Pid file ${DIR}/${PROG}.pid exists. Already running?" - exit 1 +OPTIONS=" $SOLR_HOME_OPT -Djetty.port=$PORT ${BOOTSTRAP_OPT} -Dcollection.configName=$NAME ${ZKRUN} -DzkHost=${ZKHOSTS} " +if [ "$1" == "start" ]; then + if [ -f "${PID_FILE}" ] ; then + echo "pid file ${PID_FILE} exists. Already running?" + else + java $OPTIONS -jar start.jar > $LOG_FILE & + echo $! > ${PID_FILE} fi - java $OPTIONS -jar start.jar > solr.log & - echo $$ > ${PROG}.pid -elif [ "$1" = "stop" ]; then - if [ -x "${PROG}.pid" ] ; then - kill `echo ${PROG}.pid` - rm ${PROG}.pid +elif [ "$1" == "stop" ]; then + if [ -f "${PID_FILE}" ] ; then + PID="`/bin/cat ${PID_FILE}`" + if [ "$PID" != "" ] ; then + kill $PID + /bin/rm ${PID_FILE} + else + echo "Unable to extract PID from ${PID_FILE}" + fi + else + echo "No pid file ($PID_FILE) found" fi else - echo "$0 [start|stop]" + echo "$0 [start|stop|status]" fi