Apache Solr open-source search software
SOLR-6529: fix regression in error handling introduced by using pid files for finding Solr processes on the localhost
Timothy Potterfe4182291885
diff --git a/solr/bin/solr b/solr/bin/solrindex ea8091839d6..da555e29895 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -285,7 +285,23 @@ function get_info() {fidoneelse- echo -e "\nNo Solr nodes are running.\n"+ # no pid files but check using ps just to be sure+ numSolrs=`ps waux | grep java | grep start.jar | wc -l | sed -e 's/^[ \t]*//'`+ if [ "$numSolrs" != "0" ]; then+ echo -e "\nFound $numSolrs Solr nodes: "+ for ID in `ps waux | grep java | grep start.jar | awk '{print $2}' | sort -r`+ do+ port=`jetty_port "$ID"`+ if [ "$port" != "" ]; then+ echo ""+ echo "Found Solr process $ID running on port $port"+ run_tool status -solr http://localhost:$port/solr+ echo ""+ fi+ done+ else+ echo -e "\nNo Solr nodes are running.\n"+ fifi} # end get_info@@ -711,9 +727,14 @@ if [[ "$SCRIPT_CMD" == "start" ]]; thenfielse# either stop or restart+ # see if Solr is already runningSOLR_PID=`solr_pid_by_port "$SOLR_PORT"`+ if [ "$SOLR_PID" == "" ]; then+ # not found using the pid file ... but use ps to ensure not found+ SOLR_PID=`ps waux | grep start.jar | grep $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`+ fiif [ "$SOLR_PID" != "" ]; then- stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"+ stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"elseecho -e "No process found for Solr node running on port $SOLR_PORT"fi