Apache Lucene open-source search software
SOLR-9371: Fix bin/solr script calculations - start/stop wait time and RMI_PORT
Erick Erickson1344d895f966
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 4ef106164f8..b1daf1b3200 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -382,6 +382,10 @@ Other Changes* SOLR-9533: Reload core config when a core is reloaded (Gethin James, Joel Bernstein)+* SOLR-9371: Fix bin/solr calculations for start/stop wait time and RMI_PORT.+ (Shawn Heisey via Erick Erickson)++================== 6.2.1 ==================Bug Fixesdiff --git a/solr/bin/solr b/solr/bin/solrindex 9d55e0a41f8..1d8edfa90f7 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -119,6 +119,9 @@ elseJAVA=javafi+if [ -z "$SOLR_STOP_WAIT" ]; then+ SOLR_STOP_WAIT=180+fi# test that Java exists, is executable and correct versionJAVA_VER=$("$JAVA" -version 2>&1)if [[ $? -ne 0 ]] ; then@@ -231,7 +234,7 @@ function print_usage() {echo ""echo " -p <port> Specify the port to start the Solr HTTP listener on; default is 8983"echo " The specified port (SOLR_PORT) will also be used to determine the stop port"- echo " STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(1\$SOLR_PORT). "+ echo " STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(\$SOLR_PORT+10000). "echo " For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985"echo ""echo " -d <dir> Specify the Solr server directory; defaults to server"@@ -575,9 +578,24 @@ function stop_solr() {SOLR_PID="$4"if [ "$SOLR_PID" != "" ]; then- echo -e "Sending stop command to Solr running on port $SOLR_PORT ... waiting 5 seconds to allow Jetty process $SOLR_PID to stop gracefully."+ echo -e "Sending stop command to Solr running on port $SOLR_PORT ... waiting up to $SOLR_STOP_WAIT seconds to allow Jetty process $SOLR_PID to stop gracefully.""$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS -jar "$DIR/start.jar" "STOP.PORT=$STOP_PORT" "STOP.KEY=$STOP_KEY" --stop || true- (sleep 5) &+ (loops=0+ while true+ do+ CHECK_PID=`ps auxww | awk '{print $2}' | grep -w $SOLR_PID | sort -r | tr -d ' '`+ if [ "$CHECK_PID" != "" ]; then+ slept=$((loops * 2))+ if [ $slept -lt $SOLR_STOP_WAIT ]; then+ sleep 2+ loops=$[$loops+1]+ else+ exit # subshell!+ fi+ else+ exit # subshell!+ fi+ done) &spinner $!rm -f "$SOLR_PID_DIR/solr-$SOLR_PORT.pid"else@@ -1459,7 +1477,11 @@ fiif [ "$ENABLE_REMOTE_JMX_OPTS" == "true" ]; thenif [ -z "$RMI_PORT" ]; then- RMI_PORT="1$SOLR_PORT"+ RMI_PORT=`expr $SOLR_PORT + 10000`+ if [ $RMI_PORT -gt 65535 ]; then+ echo -e "\nRMI_PORT is $RMI_PORT, which is invalid!\n"+ exit 1+ fifiREMOTE_JMX_OPTS=('-Dcom.sun.management.jmxremote' \@@ -1620,18 +1642,19 @@ function launch_solr() {# no lsof on cygwin thoughif hash lsof 2>/dev/null ; then # hash returns true if lsof is on the path- echo -n "Waiting up to 30 seconds to see Solr running on port $SOLR_PORT"+ echo -n "Waiting up to $SOLR_STOP_WAIT seconds to see Solr running on port $SOLR_PORT"# Launch in a subshell to show the spinner(loops=0while truedorunning=`lsof -PniTCP:$SOLR_PORT -sTCP:LISTEN`if [ -z "$running" ]; then- if [ $loops -lt 6 ]; then- sleep 5+ slept=$((loops * 2))+ if [ $slept -lt $SOLR_STOP_WAIT ]; then+ sleep 2loops=$[$loops+1]else- echo -e "Still not seeing Solr listening on $SOLR_PORT after 30 seconds!"+ echo -e "Still not seeing Solr listening on $SOLR_PORT after $SOLR_STOP_WAIT seconds!"tail -30 "$SOLR_LOGS_DIR/solr.log"exit # subshell!fidiff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex 40c59a6f1b9..a84c474eeea 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -21,6 +21,12 @@# affecting other Java applications on your server/workstation.#SOLR_JAVA_HOME=""+# This controls the number of seconds that the solr script will wait for+# Solr to stop gracefully or Solr to start. If the graceful stop fails,+# the script will forcibly stop Solr. If the start fails, the script will+# give up waiting and display the last few lines of the logfile.+#SOLR_STOP_WAIT="180"+# Increase Java Heap as needed to support your indexing / query needs#SOLR_HEAP="512m"