You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2014/12/02 18:54:39 UTC
svn commit: r1642967 - in /lucene/dev/branches/lucene_solr_4_10/solr:
CHANGES.txt bin/solr
Author: thelabdude
Date: Tue Dec 2 17:54:39 2014
New Revision: 1642967
URL: http://svn.apache.org/r1642967
Log:
SOLR-6653: should return error code >0 when something fails
Modified:
lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
lucene/dev/branches/lucene_solr_4_10/solr/bin/solr
Modified: lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt?rev=1642967&r1=1642966&r2=1642967&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt Tue Dec 2 17:54:39 2014
@@ -92,6 +92,10 @@ Other Changes
* SOLR-6694: Auto-detect JAVA_HOME using the Windows registry if it is not set
(janhoy, Timothy Potter)
+* SOLR-6653: bin/solr script should return error code >0 when something fails
+ (janhoy, Timothy Potter)
+
+
================== 4.10.2 ==================
Bug Fixes
Modified: lucene/dev/branches/lucene_solr_4_10/solr/bin/solr
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/bin/solr?rev=1642967&r1=1642966&r2=1642967&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/bin/solr (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/bin/solr Tue Dec 2 17:54:39 2014
@@ -51,7 +51,7 @@ hasLsof=$(which lsof)
stop_all=false
# for now, we don't support running this script from cygwin due to problems
-# like not having lsof, ps waux, curl, and awkward directory handling
+# like not having lsof, ps auxww, curl, and awkward directory handling
if [ "${THIS_OS:0:6}" == "CYGWIN" ]; then
echo -e "This script does not support cygwin due to severe limitations and lack of adherence\nto BASH standards, such as lack of lsof, curl, and ps options.\n\nPlease use the native solr.cmd script on Windows!"
exit 1
@@ -71,14 +71,7 @@ done
SOLR_TIP=`dirname "$SOLR_SCRIPT"`/..
SOLR_TIP=`cd "$SOLR_TIP"; pwd`
-
-# TODO: see SOLR-3619, need to support server or example
-# depending on the version of Solr
-if [ -e "$SOLR_TIP/server/start.jar" ]; then
- DEFAULT_SERVER_DIR=$SOLR_TIP/server
-else
- DEFAULT_SERVER_DIR=$SOLR_TIP/example
-fi
+DEFAULT_SERVER_DIR=$SOLR_TIP/example
# If an include wasn't specified in the environment, then search for one...
if [ "x$SOLR_INCLUDE" == "x" ]; then
@@ -191,10 +184,12 @@ function print_usage() {
echo ""
echo " -k <key> Stop key; default is solrrocks"
echo ""
- echo " -p <port> Specify the port the Solr HTTP listener is bound to; default is 8983"
+ echo " -p <port> Specify the port the Solr HTTP listener is bound to"
echo ""
echo " -all Find and stop all running Solr servers on this host"
echo ""
+ echo " NOTE: To see if any Solr servers are running, do: solr -i"
+ echo ""
elif [ "$CMD" == "healthcheck" ]; then
echo ""
echo "Usage: solr healthcheck [-c collection] [-z zkHost]"
@@ -227,7 +222,7 @@ function solr_pid_by_port() {
THE_PORT="$1"
if [ -e "$SOLR_TIP/bin/solr-$THE_PORT.pid" ]; then
PID=`cat $SOLR_TIP/bin/solr-$THE_PORT.pid`
- CHECK_PID=`ps waux | awk '{print $2}' | grep $PID | sort -r | tr -d ' '`
+ CHECK_PID=`ps auxww | awk '{print $2}' | grep $PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then
local solrPID=$PID
fi
@@ -238,7 +233,7 @@ function solr_pid_by_port() {
# extract the value of the -Djetty.port parameter from a running Solr process
function jetty_port() {
SOLR_PID="$1"
- SOLR_PROC=`ps waux | 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"
for arg in "${proc_args[@]}"
do
@@ -278,22 +273,22 @@ function get_info() {
port=`jetty_port "$ID"`
if [ "$port" != "" ]; then
echo ""
- echo "Found Solr process $ID running on port $port"
+ echo "Solr process $ID running on port $port"
run_tool status -solr http://localhost:$port/solr
echo ""
fi
done
else
# no pid files but check using ps just to be sure
- numSolrs=`ps waux | grep java | grep start.jar | wc -l | sed -e 's/^[ \t]*//'`
+ numSolrs=`ps auxww | grep java | grep start.jar | wc -l | sed -e 's/^[ \t]*//'`
if [ "$numSolrs" != "0" ]; then
echo -e "\nFound $numSolrs Solr nodes: "
- for ID in `ps waux | 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
port=`jetty_port "$ID"`
if [ "$port" != "" ]; then
echo ""
- echo "Found Solr process $ID running on port $port"
+ echo "Solr process $ID running on port $port"
run_tool status -solr http://localhost:$port/solr
echo ""
fi
@@ -326,7 +321,7 @@ function stop_solr() {
exit 0
fi
- CHECK_PID=`ps waux | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '`
+ CHECK_PID=`ps auxww | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then
echo -e "Solr process $SOLR_PID is still running; forcefully killing it now."
kill -9 $SOLR_PID
@@ -335,7 +330,7 @@ function stop_solr() {
sleep 1
fi
- CHECK_PID=`ps waux | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '`
+ CHECK_PID=`ps auxww | awk '{print $2}' | grep $SOLR_PID | sort -r | tr -d ' '`
if [ "$CHECK_PID" != "" ]; then
echo "ERROR: Failed to kill previous Solr Java process $SOLR_PID ... script fails."
exit 1
@@ -450,12 +445,18 @@ if [ $# -gt 0 ]; then
exit 1
fi
- # see if the arg value is relative to the tip vs full path
- if [[ $2 != /* ]] && [[ -d "$SOLR_TIP/$2" ]]; then
- SOLR_SERVER_DIR="$SOLR_TIP/$2"
+ if [[ "$2" == "." || "$2" == "./" || "$2" == ".." || "$2" == "../" ]]; then
+ SOLR_SERVER_DIR=`pwd`/$2
else
- SOLR_SERVER_DIR="$2"
+ # see if the arg value is relative to the tip vs full path
+ if [[ $2 != /* ]] && [[ -d "$SOLR_TIP/$2" ]]; then
+ SOLR_SERVER_DIR="$SOLR_TIP/$2"
+ else
+ SOLR_SERVER_DIR="$2"
+ fi
fi
+ # resolve it to an absolute path
+ SOLR_SERVER_DIR=`cd "$SOLR_SERVER_DIR"; pwd`
shift 2
;;
-s|-solr.home)
@@ -652,19 +653,19 @@ if [ "$EXAMPLE" != "" ]; then
shift
;;
default)
- SOLR_HOME="$SOLR_TIP/example/solr"
+ SOLR_HOME="$SOLR_SERVER_DIR/solr"
shift
;;
dih)
- SOLR_HOME="$SOLR_TIP/example/example-DIH/solr"
+ SOLR_HOME="$SOLR_SERVER_DIR/example-DIH/solr"
shift
;;
schemaless)
- SOLR_HOME="$SOLR_TIP/example/example-schemaless/solr"
+ SOLR_HOME="$SOLR_SERVER_DIR/example-schemaless/solr"
shift
;;
multicore)
- SOLR_HOME="$SOLR_TIP/example/multicore"
+ SOLR_HOME="$SOLR_SERVER_DIR/multicore"
shift
;;
*)
@@ -674,6 +675,11 @@ if [ "$EXAMPLE" != "" ]; then
esac
fi
+if [[ "$FG" == "true" && "$EXAMPLE" != "" ]]; then
+ FG="false"
+ echo -e "\nWARNING: Foreground mode (-f) not supported when running examples.\n"
+fi
+
if [ "$STOP_KEY" == "" ]; then
STOP_KEY="solrrocks"
fi
@@ -716,12 +722,12 @@ if [[ "$SCRIPT_CMD" == "start" ]]; then
if [ "$SOLR_PID" == "" ]; then
# not found using the pid file ... but use ps to ensure not found
- SOLR_PID=`ps waux | 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
if [ "$SOLR_PID" != "" ]; then
echo -e "\nPort $SOLR_PORT is already being used by another process (pid: $SOLR_PID)\n"
- exit
+ exit 1
fi
else
# either stop or restart
@@ -729,12 +735,13 @@ else
SOLR_PID=`solr_pid_by_port "$SOLR_PORT"`
if [ "$SOLR_PID" == "" ]; then
# not found using the pid file ... but use ps to ensure not found
- SOLR_PID=`ps waux | 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
if [ "$SOLR_PID" != "" ]; then
stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"
else
echo -e "No process found for Solr node running on port $SOLR_PORT"
+ exit 1
fi
fi
@@ -935,14 +942,14 @@ $SOLR_HOST_ARG -Djetty.port=$SOLR_PORT \
exit;
fi
else
- SOLR_PID=`ps waux | 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"
exit;
fi
done) &
spinner $!
else
- SOLR_PID=`ps waux | 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"
exit;
fi