You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2016/10/28 15:29:44 UTC
[02/12] lucene-solr:jira/solr-8593: SOLR-9371: Fix bin/solr script
calculations - start/stop wait time and RMI_PORT
SOLR-9371: Fix bin/solr script calculations - start/stop wait time and RMI_PORT
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1344d895
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1344d895
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1344d895
Branch: refs/heads/jira/solr-8593
Commit: 1344d895f96644a4d541acd5a9fbe9fe4d1969a5
Parents: fa4e599
Author: Erick Erickson <er...@apache.org>
Authored: Thu Oct 27 17:54:34 2016 -0700
Committer: Erick Erickson <er...@apache.org>
Committed: Thu Oct 27 17:54:34 2016 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 4 ++++
solr/bin/solr | 39 +++++++++++++++++++++++++++++++--------
solr/bin/solr.in.sh | 6 ++++++
3 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1344d895/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4ef1061..b1daf1b 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 Fixes
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1344d895/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 9d55e0a..1d8edfa 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -119,6 +119,9 @@ else
JAVA=java
fi
+if [ -z "$SOLR_STOP_WAIT" ]; then
+ SOLR_STOP_WAIT=180
+fi
# test that Java exists, is executable and correct version
JAVA_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 @@ fi
if [ "$ENABLE_REMOTE_JMX_OPTS" == "true" ]; then
if [ -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
+ fi
fi
REMOTE_JMX_OPTS=('-Dcom.sun.management.jmxremote' \
@@ -1620,18 +1642,19 @@ function launch_solr() {
# no lsof on cygwin though
if 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=0
while true
do
running=`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 2
loops=$[$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!
fi
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1344d895/solr/bin/solr.in.sh
----------------------------------------------------------------------
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index 40c59a6..a84c474 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"