epugh commented on code in PR #1951:
URL: https://github.com/apache/solr/pull/1951#discussion_r1335002541
##########
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() {
Review Comment:
I love the breaking down these convulted functions into smaller ones, makes
it easier to read and reason! Hell, maybe someday we bats test the functions?
--
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]