SOLR-7450: Fix grep options used when searching for numbers in bin/solr

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1675511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-04-22 22:42:19 +00:00
parent d0a159e5d7
commit e86dec2058
2 changed files with 12 additions and 9 deletions

View File

@ -165,6 +165,9 @@ Bug Fixes
* SOLR-7408: Listeners set by SolrCores on config directories in ZK could be removed if collections * SOLR-7408: Listeners set by SolrCores on config directories in ZK could be removed if collections
are created/deleted in paralle against the same config set. (Shai Erera, Anshum Gupta) are created/deleted in paralle against the same config set. (Shai Erera, Anshum Gupta)
* SOLR-7450: Fix edge case which could cause `bin/solr stop` to hang forever
(Ramkumar Aiyengar)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -335,7 +335,7 @@ function spinner() {
local pid=$1 local pid=$1
local delay=0.5 local delay=0.5
local spinstr='|/-\' local spinstr='|/-\'
while [ "$(ps aux | awk '{print $2}' | grep $pid)" ]; do while [ "$(ps aux | awk '{print $2}' | grep -w $pid)" ]; do
local temp=${spinstr#?} local temp=${spinstr#?}
printf " [%c] " "$spinstr" printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"} local spinstr=$temp${spinstr%"$temp"}
@ -350,7 +350,7 @@ function solr_pid_by_port() {
THE_PORT="$1" THE_PORT="$1"
if [ -e "$SOLR_PID_DIR/solr-$THE_PORT.pid" ]; then if [ -e "$SOLR_PID_DIR/solr-$THE_PORT.pid" ]; then
PID=`cat "$SOLR_PID_DIR/solr-$THE_PORT.pid"` PID=`cat "$SOLR_PID_DIR/solr-$THE_PORT.pid"`
CHECK_PID=`ps auxww | awk '{print $2}' | grep $PID | sort -r | tr -d ' '` CHECK_PID=`ps auxww | awk '{print $2}' | grep -w $PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then if [ "$CHECK_PID" != "" ]; then
local solrPID=$PID local solrPID=$PID
fi fi
@ -361,7 +361,7 @@ function solr_pid_by_port() {
# extract the value of the -Djetty.port parameter from a running Solr process # extract the value of the -Djetty.port parameter from a running Solr process
function jetty_port() { function jetty_port() {
SOLR_PID="$1" SOLR_PID="$1"
SOLR_PROC=`ps auxww | grep $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" IFS=' ' read -a proc_args <<< "$SOLR_PROC"
for arg in "${proc_args[@]}" for arg in "${proc_args[@]}"
do do
@ -454,7 +454,7 @@ function stop_solr() {
exit 0 exit 0
fi fi
CHECK_PID=`ps auxww | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '` CHECK_PID=`ps auxww | awk '{print $2}' | grep -w $SOLR_PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then if [ "$CHECK_PID" != "" ]; then
echo -e "Solr process $SOLR_PID is still running; forcefully killing it now." echo -e "Solr process $SOLR_PID is still running; forcefully killing it now."
kill -9 $SOLR_PID kill -9 $SOLR_PID
@ -463,7 +463,7 @@ function stop_solr() {
sleep 1 sleep 1
fi fi
CHECK_PID=`ps auxww | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '` CHECK_PID=`ps auxww | awk '{print $2}' | grep -w $SOLR_PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then if [ "$CHECK_PID" != "" ]; then
echo "ERROR: Failed to kill previous Solr Java process $SOLR_PID ... script fails." echo "ERROR: Failed to kill previous Solr Java process $SOLR_PID ... script fails."
exit 1 exit 1
@ -1082,7 +1082,7 @@ if [[ "$SCRIPT_CMD" == "stop" && -z "$SOLR_PORT" ]]; then
if [ $numSolrs -eq 1 ]; then if [ $numSolrs -eq 1 ]; then
# only do this if there is only 1 node running, otherwise they must provide the -p or -all # only do this if there is only 1 node running, otherwise they must provide the -p or -all
PID="$(cat "$(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)")" PID="$(cat "$(find "$SOLR_PID_DIR" -name "solr-*.pid" -type f)")"
CHECK_PID=`ps auxww | awk '{print $2}' | grep $PID | sort -r | tr -d ' '` CHECK_PID=`ps auxww | awk '{print $2}' | grep -w $PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then if [ "$CHECK_PID" != "" ]; then
port=`jetty_port "$CHECK_PID"` port=`jetty_port "$CHECK_PID"`
if [ "$port" != "" ]; then if [ "$port" != "" ]; then
@ -1131,7 +1131,7 @@ else
SOLR_PID=`solr_pid_by_port "$SOLR_PORT"` SOLR_PID=`solr_pid_by_port "$SOLR_PORT"`
if [ -z "$SOLR_PID" ]; then if [ -z "$SOLR_PID" ]; then
# not found using the pid file ... but use ps to ensure not found # not found using the pid file ... but use ps to ensure not found
SOLR_PID=`ps auxww | grep start\.jar | grep $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r` SOLR_PID=`ps auxww | grep start\.jar | grep -w $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r`
fi fi
if [ "$SOLR_PID" != "" ]; then if [ "$SOLR_PID" != "" ]; then
stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID" stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"
@ -1377,14 +1377,14 @@ function launch_solr() {
exit exit
fi fi
else else
SOLR_PID=`ps auxww | grep start\.jar | grep $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r` SOLR_PID=`ps auxww | grep start\.jar | grep -w $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" echo -e "\nStarted Solr server on port $SOLR_PORT (pid=$SOLR_PID). Happy searching!\n"
exit exit
fi fi
done) & done) &
spinner $! spinner $!
else else
SOLR_PID=`ps auxww | grep start\.jar | grep $SOLR_PORT | grep -v grep | awk '{print $2}' | sort -r` SOLR_PID=`ps auxww | grep start\.jar | grep -w $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" echo -e "\nStarted Solr server on port $SOLR_PORT (pid=$SOLR_PID). Happy searching!\n"
exit; exit;
fi fi