From b2bf87dee7ea1b98eed62ccc3a921d387db39a79 Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Fri, 4 Nov 2016 12:57:26 -0700 Subject: [PATCH] SOLR-9360: Solr script not properly checking SOLR_PID --- solr/CHANGES.txt | 3 +++ solr/bin/solr | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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/solr index 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 process function 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" ]; then echo -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 $PROCESSES do port=`jetty_port "$ID"` @@ -1345,7 +1345,7 @@ if [[ "$SCRIPT_CMD" == "start" ]]; then 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` fi if [ "$SOLR_PID" != "" ]; then @@ -1358,7 +1358,7 @@ else SOLR_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` fi if [ "$SOLR_PID" != "" ]; then stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID" @@ -1659,7 +1659,7 @@ function launch_solr() { exit # subshell! fi else - 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() { else echo -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