epugh commented on code in PR #1951:
URL: https://github.com/apache/solr/pull/1951#discussion_r1335002694


##########
solr/bin/solr:
##########
@@ -636,98 +637,76 @@ function run_tool() {
   return $?
 } # end run_tool function
 
-# get status about any Solr nodes running on this host
-function get_status() {
-  # first, see if Solr is running
-  numSolrs=$(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | wc -l | tr -d ' 
')
+function get_all_running_solr_processes() {
+  # 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: "
-    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 -solrUrl 
"$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr" "$@"
-          echo ""
-        else
-          echo -e "\nSolr process $ID from $PIDF not found."
-        fi
-    done < <(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)
+    PROCESSES=($(ps auxww | grep start\.jar | grep solr\.solr\.home | grep -v 
grep | awk '{print $2}' | sort -r))
+    echo "${PROCESSES[@]}"
   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: "
-      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 -solrUrl 
"$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr" "$@"
-            echo ""
-          fi
-      done
-    else
-      echo -e "\nNo Solr nodes are running.\n"
-      run_tool status "$@"
-    fi
+    echo -e "\nNo Solr nodes are running.\n" >&2
   fi
+}
 
-} # end get_status
-
-function run_package() {
-  runningSolrUrl=""
+function get_all_running_solr_ports() {
+  for ID in $(get_all_running_solr_processes); do
+    port=$(jetty_port "$ID")
+    if [ "$port" != "" ]; then
+      echo -e "\nSolr process $ID running on port $port\n" >&2
+      echo "$port"
+    fi
+  done
+}
 
-  numSolrs=$(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f | wc -l | tr -d ' 
')
-  if [ "$numSolrs" != "0" ]; then
-    #echo -e "\nFound $numSolrs Solr nodes: "
-    while read PIDF
-      do
-        ID=$(cat "$PIDF")
-        port=$(jetty_port "$ID")
-        if [ "$port" != "" ]; then
-          #echo -e "\nSolr process $ID running on port $port"
-          runningSolrUrl="$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"
-          break
-          CODE=$?
-          echo ""
-        else
-          echo -e "\nSolr process $ID from $PIDF not found."
-          CODE=1
-        fi
-    done < <(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)
+# This chooses a default solr port if one is not provided via the command line.
+#  1. If a port is provided to the function, use that.
+#  2. If a SOLR_PORT is explicitly provided, use it.
+#  3. If there is a single SOLR process running on the machine, use that.
+function choose_default_solr_port() {
+  chosen_solr_port=""
+  explicit_solr_port="${1:-}"
+  explicit_solr_port_env="${PROVIDED_SOLR_PORT_ENV}"
+
+  if [ -n "${explicit_solr_port:-}" ]; then
+    chosen_solr_port="${explicit_solr_port}"
+  elif [ -n "${explicit_solr_port_env:-}" ]; then
+    chosen_solr_port="${explicit_solr_port_env}"
   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: "
-      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"
-            runningSolrUrl="$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"
-            break
-            CODE=$?
-            echo ""
-          fi
-      done
+    # no-commit - check if the SOLR_TOOL_HOST is the localhost, otherwise 
don't do this

Review Comment:
   I never quite understood what `SOLR_TOOL_HOST` gave us that `SOLR_HOST` 
doesn't!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to