Apache Lucene open-source search software
SOLR-7169: bin/solr status should return exit code 3 no Solr is running instead of 0
Timothy Potterc862370abe83
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 388e21bf4a0..7868361833e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -422,6 +422,9 @@ Bug Fixes* SOLR-8073: Solr fails to start on Windows with obscure errors when using relative path.(Alexandre Rafalovitch, Ishan Chattopadhyaya via shalin)+* SOLR-7169: bin/solr status should return exit code 3, not 0 if Solr is not running+ (Dominik Siebel via Timothy Potter)+Optimizations----------------------diff --git a/solr/bin/solr b/solr/bin/solrindex a398d24b412..75eab7ada59 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -423,42 +423,49 @@ function run_tool() {# get information about any Solr nodes running on this hostfunction get_info() {+ CODE=4# first, see if Solr is runningnumSolrs=`find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | wc -l | tr -d ' '`if [ "$numSolrs" != "0" ]; thenecho -e "\nFound $numSolrs Solr nodes: "- find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | while read PIDF+ while read PIDFdoID=`cat "$PIDF"`port=`jetty_port "$ID"`if [ "$port" != "" ]; thenecho -e "\nSolr process $ID running on port $port"run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"+ CODE=$?echo ""elseecho -e "\nSolr process $ID from $PIDF not found."+ CODE=1fi- done+ done < <(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)else# no pid files but check using ps just to be surenumSolrs=`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: "- for ID in `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"`if [ "$port" != "" ]; thenecho ""echo "Solr process $ID running on port $port"run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"+ CODE=$?echo ""fidoneelseecho -e "\nNo Solr nodes are running.\n"+ CODE=3fifi-++ return $CODE} # end get_info# tries to gracefully stop Solr using the Jetty@@ -506,7 +513,7 @@ if [ $# -eq 1 ]; then;;-info|-i|status)get_info- exit+ exit $?;;-version|-v|version)run_tool version