Apache Lucene open-source search software
SOLR-9360: Solr script not properly checking SOLR_PID
Erick Ericksonb2bf87dee7ea
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 8f92744662c..0411092c8ad 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -111,6 +111,9 @@ Bug Fixes* SOLR-9433: SolrCore clean-up logic uses incorrect path to delete dataDir on failure to create a core.(Evan Sayer, shalin)+* SOLR-9360: Solr script not properly checking SOLR_PID+ (Alessandro Benedetti via Erick Erickson)+Other Changes----------------------diff --git a/solr/bin/solr b/solr/bin/solrindex 1d8edfa90f7..880fcef9981 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -495,7 +495,7 @@ function solr_pid_by_port() {# extract the value of the -Djetty.port parameter from a running Solr processfunction jetty_port() {SOLR_PID="$1"- SOLR_PROC=`ps auxww | grep -w $SOLR_PID | grep start\.jar | grep jetty.port`+ SOLR_PROC=`ps auxww | grep -w $SOLR_PID | grep start\.jar | grep jetty\.port`IFS=' ' read -a proc_args <<< "$SOLR_PROC"for arg in "${proc_args[@]}"do@@ -543,10 +543,10 @@ function get_info() {done < <(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)else# no pid files but check using ps just to be sure- numSolrs=`ps auxww | grep start\.jar | grep solr.solr.home | grep -v grep | wc -l | sed -e 's/^[ \t]*//'`+ numSolrs=`ps auxww | grep start\.jar | grep solr\.solr\.home | grep -v grep | wc -l | sed -e 's/^[ \t]*//'`if [ "$numSolrs" != "0" ]; thenecho -e "\nFound $numSolrs Solr nodes: "- PROCESSES=$(ps auxww | grep start\.jar | grep solr.solr.home | grep -v grep | awk '{print $2}' | sort -r)+ PROCESSES=$(ps auxww | grep start\.jar | grep solr\.solr\.home | grep -v grep | awk '{print $2}' | sort -r)for ID in $PROCESSESdoport=`jetty_port "$ID"`@@ -1345,7 +1345,7 @@ if [[ "$SCRIPT_CMD" == "start" ]]; thenif [ -z "$SOLR_PID" ]; then# not found using the pid file ... but use ps to ensure not found- SOLR_PID=`ps auxww | grep start\.jar | grep -w $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`+ SOLR_PID=`ps auxww | grep start\.jar | grep -w "\-Djetty\.port=$SOLR_PORT" | grep -v grep | awk '{print $2}' | sort -r`fiif [ "$SOLR_PID" != "" ]; then@@ -1358,7 +1358,7 @@ elseSOLR_PID=`solr_pid_by_port "$SOLR_PORT"`if [ -z "$SOLR_PID" ]; then# not found using the pid file ... but use ps to ensure not found- SOLR_PID=`ps auxww | grep start\.jar | grep -w $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`+ SOLR_PID=`ps auxww | grep start\.jar | grep -w "\-Djetty\.port=$SOLR_PORT" | grep -v grep | awk '{print $2}' | sort -r`fiif [ "$SOLR_PID" != "" ]; thenstop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"@@ -1659,7 +1659,7 @@ function launch_solr() {exit # subshell!fielse- SOLR_PID=`ps auxww | grep start\.jar | grep -w $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`+ SOLR_PID=`ps auxww | grep start\.jar | grep -w "\-Djetty\.port=$SOLR_PORT" | grep -v grep | awk '{print $2}' | sort -r`echo -e "\nStarted Solr server on port $SOLR_PORT (pid=$SOLR_PID). Happy searching!\n"exit # subshell!fi@@ -1668,7 +1668,7 @@ function launch_solr() {elseecho -e "NOTE: Please install lsof as this script needs it to determine if Solr is listening on port $SOLR_PORT."sleep 10- SOLR_PID=`ps auxww | grep start\.jar | grep -w $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`+ SOLR_PID=`ps auxww | grep start\.jar | grep -w "\-Djetty\.port=$SOLR_PORT" | grep -v grep | awk '{print $2}' | sort -r`echo -e "\nStarted Solr server on port $SOLR_PORT (pid=$SOLR_PID). Happy searching!\n"return;fi