SOLR-7195: bin/solr changes: Escape start.jar in greps. Fix incorrect substring port detection.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1665405 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shawn Heisey 2015-03-10 04:39:51 +00:00
parent 9563a30751
commit 208e1f9156
2 changed files with 15 additions and 9 deletions

View File

@ -214,6 +214,12 @@ Bug Fixes
* SOLR-7209: /update/json/docs carry forward fields from previous records (Noble Paul) * SOLR-7209: /update/json/docs carry forward fields from previous records (Noble Paul)
* SOLR-7195: Fixed a bug where the bin/solr shell script would incorrectly
detect another Solr process listening on the same port number. If the
requested listen port was 8983, it would match on another Solr using port
18983 for any purpose. Also escapes the dot character in all grep commands
looking for start.jar.
(Xu Zhang via Shawn Heisey)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -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 $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
@ -410,10 +410,10 @@ function get_info() {
done done
else else
# no pid files but check using ps just to be sure # 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]*//'` numSolrs=`ps auxww | grep start\.jar | grep solr.solr.home | grep -v grep | wc -l | sed -e 's/^[ \t]*//'`
if [ "$numSolrs" != "0" ]; then if [ "$numSolrs" != "0" ]; then
echo -e "\nFound $numSolrs Solr nodes: " 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` for ID in `ps auxww | grep start\.jar | grep solr.solr.home | grep -v grep | awk '{print $2}' | sort -r`
do do
port=`jetty_port "$ID"` port=`jetty_port "$ID"`
if [ "$port" != "" ]; then if [ "$port" != "" ]; then
@ -658,7 +658,7 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
fi fi
if [ -z "$CREATE_PORT" ]; then if [ -z "$CREATE_PORT" ]; then
for ID in `ps auxww | grep java | grep start.jar | awk '{print $2}' | sort -r` for ID in `ps auxww | grep java | grep start\.jar | awk '{print $2}' | sort -r`
do do
port=`jetty_port "$ID"` port=`jetty_port "$ID"`
if [ "$port" != "" ]; then if [ "$port" != "" ]; then
@ -748,7 +748,7 @@ if [[ "$SCRIPT_CMD" == "delete" ]]; then
fi fi
if [ -z "$DELETE_PORT" ]; then if [ -z "$DELETE_PORT" ]; then
for ID in `ps auxww | grep java | grep start.jar | awk '{print $2}' | sort -r` for ID in `ps auxww | grep java | grep start\.jar | awk '{print $2}' | sort -r`
do do
port=`jetty_port "$ID"` port=`jetty_port "$ID"`
if [ "$port" != "" ]; then if [ "$port" != "" ]; then
@ -1112,7 +1112,7 @@ if [[ "$SCRIPT_CMD" == "start" ]]; then
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
@ -1125,7 +1125,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 $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"
@ -1369,14 +1369,14 @@ $SOLR_OPTS"
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 $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 $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