summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-10-17 14:40:39 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-10-17 14:40:39 +0100
commit3bec5bb023e7ae5021bc2f21ed5dcbb1a94ea2a6 (patch)
tree863fdba36bd64d26ca638fe12579bc77525c03ca
parent5198e99b0e697ae022abfacdaf2fcf4808a9ff19 (diff)
downloadrabbitmq-server-3bec5bb023e7ae5021bc2f21ed5dcbb1a94ea2a6.tar.gz
Add RABBITMQ_USE_LONGNAME. Based on a patch from Marcos Diez but with fixes for the new way rabbitmqctl starts distribution, refactoring of common stuff into rabbitmq-env, not trimming the hostname, etc.
-rw-r--r--scripts/rabbitmq-echopid.bat14
-rwxr-xr-xscripts/rabbitmq-env13
-rwxr-xr-xscripts/rabbitmq-plugins2
-rwxr-xr-xscripts/rabbitmq-plugins.bat10
-rwxr-xr-xscripts/rabbitmq-server4
-rwxr-xr-xscripts/rabbitmq-server.bat12
-rwxr-xr-xscripts/rabbitmq-service.bat12
-rwxr-xr-xscripts/rabbitmqctl3
-rwxr-xr-xscripts/rabbitmqctl.bat10
-rw-r--r--src/rabbit_control_main.erl10
10 files changed, 74 insertions, 16 deletions
diff --git a/scripts/rabbitmq-echopid.bat b/scripts/rabbitmq-echopid.bat
index 5c652c30..2d3a6fa4 100644
--- a/scripts/rabbitmq-echopid.bat
+++ b/scripts/rabbitmq-echopid.bat
@@ -2,7 +2,7 @@
REM Usage: rabbitmq-echopid.bat <rabbitmq_nodename>
REM
-REM <rabbitmq_nodename> sname of the erlang node to connect to (required)
+REM <rabbitmq_nodename> (s)name of the erlang node to connect to (required)
setlocal
@@ -18,8 +18,18 @@ if not exist "%WMIC_PATH%" (
goto fail
)
+:: sets sname/name ::
+if "!RABBITMQ_USE_LONGNAME!"=="" (
+ set RABBITMQ_NAME_TYPE="-sname"
+)
+
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE="-name"
+)
+
+
:getpid
-for /f "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%-sname %1%%'" get processid 2^>nul`) do (
+for /f "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NAME_TYPE% %1%%'" get processid 2^>nul`) do (
set PID=%%P
goto echopid
)
diff --git a/scripts/rabbitmq-env b/scripts/rabbitmq-env
index 74298440..8b0e1ccd 100755
--- a/scripts/rabbitmq-env
+++ b/scripts/rabbitmq-env
@@ -39,8 +39,17 @@ set -e
SCRIPT_DIR=`dirname $SCRIPT_PATH`
RABBITMQ_HOME="${SCRIPT_DIR}/.."
-[ "x" = "x$HOSTNAME" ] && HOSTNAME=`env hostname`
-NODENAME=rabbit@${HOSTNAME%%.*}
+
+[ "x" = "x$RABBITMQ_USE_LONGNAME" ] && RABBITMQ_USE_LONGNAME=${USE_LONGNAME}
+if [ "xtrue" = "x$RABBITMQ_USE_LONGNAME" ] ; then
+ RABBITMQ_NAME_TYPE=-name
+ [ "x" = "x$HOSTNAME" ] && HOSTNAME=`env hostname --fqdn`
+ NODENAME=rabbit@${HOSTNAME}
+else
+ RABBITMQ_NAME_TYPE=-sname
+ [ "x" = "x$HOSTNAME" ] && HOSTNAME=`env hostname`
+ NODENAME=rabbit@${HOSTNAME%%.*}
+fi
## Set defaults
. ${SCRIPT_DIR}/rabbitmq-defaults
diff --git a/scripts/rabbitmq-plugins b/scripts/rabbitmq-plugins
index 8b5b30b7..29c4b0c8 100755
--- a/scripts/rabbitmq-plugins
+++ b/scripts/rabbitmq-plugins
@@ -23,7 +23,7 @@ exec ${ERL_DIR}erl \
-pa "${RABBITMQ_HOME}/ebin" \
-noinput \
-hidden \
- -sname rabbitmq-plugins$$ \
+ ${RABBITMQ_NAME_TYPE} rabbitmq-plugins$$ \
-boot "${CLEAN_BOOT_FILE}" \
-s rabbit_plugins_main \
-enabled_plugins_file "$RABBITMQ_ENABLED_PLUGINS_FILE" \
diff --git a/scripts/rabbitmq-plugins.bat b/scripts/rabbitmq-plugins.bat
index 61e39e38..1fc0e733 100755
--- a/scripts/rabbitmq-plugins.bat
+++ b/scripts/rabbitmq-plugins.bat
@@ -23,6 +23,14 @@ set TDP0=%~dp0
set STAR=%*
setlocal enabledelayedexpansion
+if "!RABBITMQ_USE_LONGNAME!"=="" (
+ set RABBITMQ_NAME_TYPE="-sname"
+)
+
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE="-name"
+)
+
if "!RABBITMQ_SERVICENAME!"=="" (
set RABBITMQ_SERVICENAME=RabbitMQ
)
@@ -55,7 +63,7 @@ if "!RABBITMQ_PLUGINS_DIR!"=="" (
set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins
)
-"!ERLANG_HOME!\bin\erl.exe" -pa "!TDP0!..\ebin" -noinput -hidden -sname rabbitmq-plugins!RANDOM!!TIME:~9! -s rabbit_plugins_main -enabled_plugins_file "!RABBITMQ_ENABLED_PLUGINS_FILE!" -plugins_dist_dir "!RABBITMQ_PLUGINS_DIR:\=/!" -nodename !RABBITMQ_NODENAME! -extra !STAR!
+"!ERLANG_HOME!\bin\erl.exe" -pa "!TDP0!..\ebin" -noinput -hidden %RABBITMQ_NAME_TYPE% rabbitmq-plugins!RANDOM!!TIME:~9! -s rabbit_plugins_main -enabled_plugins_file "!RABBITMQ_ENABLED_PLUGINS_FILE!" -plugins_dist_dir "!RABBITMQ_PLUGINS_DIR:\=/!" -nodename !RABBITMQ_NODENAME! -extra !STAR!
endlocal
endlocal
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 96458094..aea8bfc9 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -54,7 +54,7 @@ RABBITMQ_DIST_PORT=$RABBITMQ_DIST_PORT \
-noinput \
-hidden \
-s rabbit_prelaunch \
- -sname rabbitmqprelaunch$$ \
+ ${RABBITMQ_NAME_TYPE} rabbitmqprelaunch$$ \
-extra "${RABBITMQ_NODENAME}"
PRELAUNCH_RESULT=$?
@@ -85,7 +85,7 @@ RABBITMQ_CONFIG_FILE=$RABBITMQ_CONFIG_FILE \
exec ${ERL_DIR}erl \
-pa ${RABBITMQ_EBIN_ROOT} \
${RABBITMQ_START_RABBIT} \
- -sname ${RABBITMQ_NODENAME} \
+ ${RABBITMQ_NAME_TYPE} ${RABBITMQ_NODENAME} \
-boot "${SASL_BOOT_FILE}" \
${RABBITMQ_CONFIG_ARG} \
+W w \
diff --git a/scripts/rabbitmq-server.bat b/scripts/rabbitmq-server.bat
index e2312406..1be96d52 100755
--- a/scripts/rabbitmq-server.bat
+++ b/scripts/rabbitmq-server.bat
@@ -23,6 +23,14 @@ set TDP0=%~dp0
set STAR=%*
setlocal enabledelayedexpansion
+if "!RABBITMQ_USE_LONGNAME!"=="" (
+ set RABBITMQ_NAME_TYPE="-sname"
+)
+
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE="-name"
+)
+
if "!RABBITMQ_BASE!"=="" (
set RABBITMQ_BASE=!APPDATA!\RabbitMQ
)
@@ -104,7 +112,7 @@ set RABBITMQ_EBIN_ROOT=!TDP0!..\ebin
-pa "!RABBITMQ_EBIN_ROOT!" ^
-noinput -hidden ^
-s rabbit_prelaunch ^
- -sname rabbitmqprelaunch!RANDOM!!TIME:~9! ^
+ %RABBITMQ_NAME_TYPE% rabbitmqprelaunch!RANDOM!!TIME:~9! ^
-extra "!RABBITMQ_NODENAME!"
if ERRORLEVEL 2 (
@@ -140,7 +148,7 @@ if not "!RABBITMQ_NODE_IP_ADDRESS!"=="" (
-boot start_sasl ^
-s rabbit boot ^
!RABBITMQ_CONFIG_ARG! ^
--sname !RABBITMQ_NODENAME! ^
+%RABBITMQ_NAME_TYPE% !RABBITMQ_NODENAME! ^
+W w ^
+A30 ^
+P 1048576 ^
diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat
index fb2703f2..73aa3c52 100755
--- a/scripts/rabbitmq-service.bat
+++ b/scripts/rabbitmq-service.bat
@@ -33,6 +33,14 @@ if "%1"=="" goto after_loop
goto loop1
:after_loop
+if "!RABBITMQ_USE_LONGNAME!"=="" (
+ set RABBITMQ_NAME_TYPE="-sname"
+)
+
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE="-name"
+)
+
if "!RABBITMQ_SERVICENAME!"=="" (
set RABBITMQ_SERVICENAME=RabbitMQ
)
@@ -184,7 +192,7 @@ if "!RABBITMQ_CONFIG_FILE!"=="" (
-pa "!RABBITMQ_EBIN_ROOT!" ^
-noinput -hidden ^
-s rabbit_prelaunch ^
- -sname rabbitmqprelaunch!RANDOM!!TIME:~9!
+ %RABBITMQ_NAME_TYPE% rabbitmqprelaunch!RANDOM!!TIME:~9!
if ERRORLEVEL 3 (
rem ERRORLEVEL means (or greater) so we need to catch all other failure
@@ -247,7 +255,7 @@ set ERLANG_SERVICE_ARGUMENTS=!ERLANG_SERVICE_ARGUMENTS:"=\"!
-env ERL_CRASH_DUMP="!RABBITMQ_BASE:\=/!/erl_crash.dump" ^
-workdir "!RABBITMQ_BASE!" ^
-stopaction "rabbit:stop_and_halt()." ^
--sname !RABBITMQ_NODENAME! ^
+%RABBITMQ_NAME_TYPE% !RABBITMQ_NODENAME! ^
!CONSOLE_FLAG! ^
-comment "A robust and scalable messaging broker" ^
-args "!ERLANG_SERVICE_ARGUMENTS!" > NUL
diff --git a/scripts/rabbitmqctl b/scripts/rabbitmqctl
index 31fe0afc..804c0c81 100755
--- a/scripts/rabbitmqctl
+++ b/scripts/rabbitmqctl
@@ -21,11 +21,12 @@
# rabbitmqctl starts distribution itself, so we need to make sure epmd
# is running.
-${ERL_DIR}erl -sname rabbitmqctl-prelaunch-$$ -noinput -eval 'erlang:halt().'
+${ERL_DIR}erl ${RABBITMQ_NAME_TYPE} rabbitmqctl-prelaunch-$$ -noinput -eval 'erlang:halt().'
# We specify Mnesia dir and sasl error logger since some actions
# (e.g. forget_cluster_node --offline) require us to impersonate the
# real node.
+RABBITMQ_USE_LONGNAME=${RABBITMQ_USE_LONGNAME} \
exec ${ERL_DIR}erl \
-pa "${RABBITMQ_HOME}/ebin" \
-noinput \
diff --git a/scripts/rabbitmqctl.bat b/scripts/rabbitmqctl.bat
index 7a2c454c..c549dd59 100755
--- a/scripts/rabbitmqctl.bat
+++ b/scripts/rabbitmqctl.bat
@@ -27,6 +27,14 @@ if "!RABBITMQ_BASE!"=="" (
set RABBITMQ_BASE=!APPDATA!\RabbitMQ
)
+if "!RABBITMQ_USE_LONGNAME!"=="" (
+ set RABBITMQ_NAME_TYPE="-sname"
+)
+
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE="-name"
+)
+
if "!COMPUTERNAME!"=="" (
set COMPUTERNAME=localhost
)
@@ -57,7 +65,7 @@ if not exist "!ERLANG_HOME!\bin\erl.exe" (
rem rabbitmqctl starts distribution itself, so we need to make sure epmd
rem is running.
-"!ERLANG_HOME!\bin\erl.exe" -sname rabbitmqctl-prelaunch-!RANDOM!!TIME:~9! -noinput -eval "erlang:halt()."
+"!ERLANG_HOME!\bin\erl.exe" %RABBITMQ_NAME_TYPE% rabbitmqctl-prelaunch-!RANDOM!!TIME:~9! -noinput -eval "erlang:halt()."
"!ERLANG_HOME!\bin\erl.exe" ^
-pa "!TDP0!..\ebin" ^
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index afc2caa0..6e789e37 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -586,7 +586,7 @@ exit_loop(Port) ->
start_distribution() ->
CtlNodeName = rabbit_misc:format("rabbitmqctl-~s", [os:getpid()]),
- {ok, _} = net_kernel:start([list_to_atom(CtlNodeName), shortnames]).
+ {ok, _} = net_kernel:start([list_to_atom(CtlNodeName), name_type()]).
become(BecomeNode) ->
case net_adm:ping(BecomeNode) of
@@ -594,12 +594,18 @@ become(BecomeNode) ->
pang -> io:format(" * Impersonating node: ~s...", [BecomeNode]),
error_logger:tty(false),
ok = net_kernel:stop(),
- {ok, _} = net_kernel:start([BecomeNode, shortnames]),
+ {ok, _} = net_kernel:start([BecomeNode, name_type()]),
io:format(" done~n", []),
Dir = mnesia:system_info(directory),
io:format(" * Mnesia directory : ~s~n", [Dir])
end.
+name_type() ->
+ case os:getenv("RABBITMQ_USE_LONGNAME") of
+ "true" -> longnames;
+ _ -> shortnames
+ end.
+
%%----------------------------------------------------------------------------
default_if_empty(List, Default) when is_list(List) ->