You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by nk...@apache.org on 2016/02/08 23:35:37 UTC

[02/50] [abbrv] lucene-solr git commit: SOLR-7169: bin/solr status should return exit code 3 no Solr is running instead of 0

SOLR-7169: bin/solr status should return exit code 3 no Solr is running instead of 0

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_5_4@1716518 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4099e25f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4099e25f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4099e25f

Branch: refs/heads/branch_5_4
Commit: 4099e25f068fe05a2a2fe3c046dec12e16564bb5
Parents: 0079a41
Author: Timothy Potter <th...@apache.org>
Authored: Wed Nov 25 19:30:32 2015 +0000
Committer: Timothy Potter <th...@apache.org>
Committed: Wed Nov 25 19:30:32 2015 +0000

----------------------------------------------------------------------
 solr/CHANGES.txt |  3 +++
 solr/bin/solr    | 17 ++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4099e25f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d0f54b1..d264367 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -269,6 +269,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
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4099e25f/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 92f54dd..85cd550 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 host
 function get_info() {
+  CODE=4
   # first, see if Solr is running
   numSolrs=`find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | wc -l | tr -d ' '`
   if [ "$numSolrs" != "0" ]; then
     echo -e "\nFound $numSolrs Solr nodes: "
-    find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | while read PIDF
+    while read PIDF
       do
         ID=`cat "$PIDF"`
         port=`jetty_port "$ID"`
         if [ "$port" != "" ]; then
           echo -e "\nSolr process $ID running on port $port"
           run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"
+          CODE=$?
           echo ""
         else
           echo -e "\nSolr process $ID from $PIDF not found."
+          CODE=1
         fi
-    done
+    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]*//'`
     if [ "$numSolrs" != "0" ]; then
       echo -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 $PROCESSES
         do
           port=`jetty_port "$ID"`
           if [ "$port" != "" ]; then
             echo ""
             echo "Solr process $ID running on port $port"
             run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"
+            CODE=$?
             echo ""
           fi
       done
     else
       echo -e "\nNo Solr nodes are running.\n"
+      CODE=3
     fi
   fi
-  
+
+  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