SOLR-6486: solr start script can have a debug flag option; use -a to set arbitrary options.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1626833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy Potter 2014-09-22 16:48:32 +00:00
parent 6efd37464f
commit 5703c00949
3 changed files with 65 additions and 38 deletions

View File

@ -249,6 +249,9 @@ Other Changes
* SOLR-6115: Cleanup enum/string action types in Overseer, OverseerCollectionProcessor and * SOLR-6115: Cleanup enum/string action types in Overseer, OverseerCollectionProcessor and
CollectionHandler. (Erick Erickson, shalin) CollectionHandler. (Erick Erickson, shalin)
* SOLR-6486: solr start script can have a debug flag option; use -a to set arbitrary options
(Noble Paul, Timothy Potter)
================== 4.10.0 ================= ================== 4.10.0 =================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -117,7 +117,7 @@ function print_usage() {
echo "" echo ""
elif [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then elif [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
echo "" echo ""
echo "Usage: solr $CMD [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-V]" echo "Usage: solr $CMD [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-a \"additional-options\"] [-V]"
echo "" echo ""
echo " -f Start Solr in foreground; default starts Solr in the background" echo " -f Start Solr in foreground; default starts Solr in the background"
echo " and sends stdout / stderr to solr-PORT-console.log" echo " and sends stdout / stderr to solr-PORT-console.log"
@ -144,13 +144,18 @@ function print_usage() {
echo " schemaless: Schema-less example" echo " schemaless: Schema-less example"
echo " multicore: Multicore" echo " multicore: Multicore"
echo "" echo ""
echo " -a Additional parameters to pass to the JVM when starting Solr, such as to setup"
echo " Java debug options. For example, to enable a Java debugger to attach to the Solr JVM"
echo " you could pass: -a \"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983\""
echo " In most cases, you should wrap the additional parameters in double quotes."
echo ""
echo " -noprompt Don't prompt for input; accept all defaults when running examples that accept user input" echo " -noprompt Don't prompt for input; accept all defaults when running examples that accept user input"
echo "" echo ""
echo " -V Verbose messages from this script" echo " -V Verbose messages from this script"
echo "" echo ""
elif [ "$CMD" == "stop" ]; then elif [ "$CMD" == "stop" ]; then
echo "" echo ""
echo "Usage: solr stop [-k key] [-p port]" echo "Usage: solr stop [-k key] [-p port] [-V]"
echo "" echo ""
echo " -k <key> Stop key; default is solrrocks" echo " -k <key> Stop key; default is solrrocks"
echo "" echo ""
@ -452,6 +457,10 @@ if [ $# -gt 0 ]; then
ZK_HOST="$2" ZK_HOST="$2"
shift 2 shift 2
;; ;;
-a|-addlopts)
ADDITIONAL_CMD_OPTS="$2"
shift 2
;;
-help|-usage) -help|-usage)
print_usage "$SCRIPT_CMD" print_usage "$SCRIPT_CMD"
exit 0 exit 0
@ -815,7 +824,7 @@ $SOLR_HOST_ARG -Djetty.port=$SOLR_PORT \
} }
if [ "$EXAMPLE" != "cloud" ]; then if [ "$EXAMPLE" != "cloud" ]; then
launch_solr "$FG" "" launch_solr "$FG" "$ADDITIONAL_CMD_OPTS"
else else
# #
# SolrCloud example is a bit involved so needs special handling here # SolrCloud example is a bit involved so needs special handling here
@ -827,7 +836,7 @@ else
echo -e "solr start -cloud -d node1 -p $SOLR_PORT \n\n" echo -e "solr start -cloud -d node1 -p $SOLR_PORT \n\n"
# can't launch this node in the foreground else we can't run anymore commands # can't launch this node in the foreground else we can't run anymore commands
launch_solr "false" "" launch_solr "false" "$ADDITIONAL_CMD_OPTS"
zk_port=$[$SOLR_PORT+1000] zk_port=$[$SOLR_PORT+1000]
zk_host=localhost:$zk_port zk_host=localhost:$zk_port

View File

@ -92,7 +92,7 @@ goto done
:start_usage :start_usage
@echo. @echo.
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-V] @echo Usage: solr %SCRIPT_CMD% [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-a "additional-options"] [-V]
@echo. @echo.
@echo -f Start Solr in foreground; default starts Solr in the background @echo -f Start Solr in foreground; default starts Solr in the background
@echo and sends stdout / stderr to solr-PORT-console.log @echo and sends stdout / stderr to solr-PORT-console.log
@ -119,6 +119,11 @@ goto done
@echo schemaless: Schema-less example @echo schemaless: Schema-less example
@echo multicore: Multicore @echo multicore: Multicore
@echo. @echo.
@echo -a opts Additional parameters to pass to the JVM when starting Solr, such as to setup
@echo Java debug options. For example, to enable a Java debugger to attach to the Solr JVM
@echo you could pass: -a "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983"
@echo In most cases, you should wrap the additional parameters in double quotes.
@echo.
@echo -noprompt Don't prompt for input; accept all defaults when running examples that accept user input @echo -noprompt Don't prompt for input; accept all defaults when running examples that accept user input
@echo. @echo.
@echo -V Verbose messages from this script @echo -V Verbose messages from this script
@ -182,6 +187,8 @@ IF "%1"=="-p" goto set_port
IF "%1"=="-port" goto set_port IF "%1"=="-port" goto set_port
IF "%1"=="-z" goto set_zookeeper IF "%1"=="-z" goto set_zookeeper
IF "%1"=="-zkhost" goto set_zookeeper IF "%1"=="-zkhost" goto set_zookeeper
IF "%1"=="-a" goto set_addl_opts
IF "%1"=="-addlopts" goto set_addl_opts
IF "%1"=="-noprompt" goto set_noprompt IF "%1"=="-noprompt" goto set_noprompt
IF NOT "%1"=="" goto invalid_cmd_line IF NOT "%1"=="" goto invalid_cmd_line
process_script_cmd process_script_cmd
@ -208,7 +215,7 @@ goto parse_args
:set_server_dir :set_server_dir
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected directory but found %2 instead! set SCRIPT_ERROR=Expected directory but found %2 instead!
@ -216,10 +223,10 @@ IF "%firstChar%"=="-" (
) )
REM See if they are using a short-hand name relative from the Solr tip directory REM See if they are using a short-hand name relative from the Solr tip directory
IF EXIST "%SOLR_TIP%\%2" ( IF EXIST "%SOLR_TIP%\%~2" (
set "SOLR_SERVER_DIR=%SOLR_TIP%\%2" set "SOLR_SERVER_DIR=%SOLR_TIP%\%~2"
) ELSE ( ) ELSE (
set "SOLR_SERVER_DIR=%2" set "SOLR_SERVER_DIR=%~2"
) )
SHIFT SHIFT
SHIFT SHIFT
@ -227,69 +234,77 @@ goto parse_args
:set_example :set_example
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected example name but found %2 instead! set SCRIPT_ERROR=Expected example name but found %2 instead!
goto invalid_cmd_line goto invalid_cmd_line
) )
set EXAMPLE=%2 set EXAMPLE=%~2
SHIFT SHIFT
SHIFT SHIFT
goto parse_args goto parse_args
:set_memory :set_memory
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected memory setting but found %2 instead! set SCRIPT_ERROR=Expected memory setting but found %2 instead!
goto invalid_cmd_line goto invalid_cmd_line
) )
set SOLR_HEAP=%2 set SOLR_HEAP=%~2
@echo SOLR_HEAP=%SOLR_HEAP% @echo SOLR_HEAP=%SOLR_HEAP%
SHIFT SHIFT
SHIFT SHIFT
goto parse_args goto parse_args
:set_host :set_host
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected hostname but found %2 instead! set SCRIPT_ERROR=Expected hostname but found %2 instead!
goto invalid_cmd_line goto invalid_cmd_line
) )
set SOLR_HOST=%2 set SOLR_HOST=%~2
SHIFT SHIFT
SHIFT SHIFT
goto parse_args goto parse_args
:set_port :set_port
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected port but found %2 instead! set SCRIPT_ERROR=Expected port but found %2 instead!
goto invalid_cmd_line goto invalid_cmd_line
) )
set SOLR_PORT=%2 set SOLR_PORT=%~2
SHIFT SHIFT
SHIFT SHIFT
goto parse_args goto parse_args
:set_zookeeper :set_zookeeper
set "arg=%2" set "arg=%~2"
set firstChar=%arg:~0,1% set firstChar=%arg:~0,1%
IF "%firstChar%"=="-" ( IF "%firstChar%"=="-" (
set SCRIPT_ERROR=Expected ZooKeeper connection string but found %2 instead! set SCRIPT_ERROR=Expected ZooKeeper connection string but found %2 instead!
goto invalid_cmd_line goto invalid_cmd_line
) )
set "ZK_HOST=%2" set "ZK_HOST=%~2"
SHIFT
SHIFT
goto parse_args
:set_addl_opts
set "arg=%~2"
set "SOLR_ADDL_ARGS=%~2"
SHIFT SHIFT
SHIFT SHIFT
goto parse_args goto parse_args
@ -656,13 +671,13 @@ IF "%1"=="/?" goto usage
goto run_healthcheck goto run_healthcheck
:set_healthcheck_collection :set_healthcheck_collection
set HEALTHCHECK_COLLECTION=%2 set HEALTHCHECK_COLLECTION=%~2
SHIFT SHIFT
SHIFT SHIFT
goto parse_healthcheck_args goto parse_healthcheck_args
:set_healthcheck_zk :set_healthcheck_zk
set HEALTHCHECK_ZK_HOST=%2 set HEALTHCHECK_ZK_HOST=%~2
SHIFT SHIFT
SHIFT SHIFT
goto parse_healthcheck_args goto parse_healthcheck_args