X-Git-Url: http://git.indexdata.com/?p=lui-solr.git;a=blobdiff_plain;f=scripts%2Fzookeeper.sh;h=50491e45d21c8fc064fc779b35d8af2d226879a1;hp=36ea6bb5cca40c104bbd93384874c3081f832829;hb=dbd01a6924b459410829a2d16e13e3a147492276;hpb=76d73113acd5a7f0ba06c550d55bf268141cc788 diff --git a/scripts/zookeeper.sh b/scripts/zookeeper.sh old mode 100644 new mode 100755 index 36ea6bb..50491e4 --- a/scripts/zookeeper.sh +++ b/scripts/zookeeper.sh @@ -1,8 +1,64 @@ -cd example -java -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DzkRun -DzkHost=localhost:9983,localhost:8574,localhost:9900 -DnumShards=2 -jar start.jar > solr.log & -cd ../example2 -java -Djetty.port=7574 -DzkRun -DzkHost=localhost:9983,localhost:8574,localhost:9900 -jar start.jar > solr.log & -cd ../exampleB -java -Djetty.port=8900 -DzkRun -DzkHost=localhost:9983,localhost:8574,localhost:9900 -jar start.jar > solr.log & -cd ../example2B -java -Djetty.port=7500 -DzkHost=localhost:9983,localhost:8574,localhost:9900 -jar start.jar > solr.log & \ No newline at end of file +#!/bin/bash + +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} + +if [ -f "$OPTIONS" ]; then + source $OPTIONS +else + 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 + +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 +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|status]" +fi