summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-03-12 13:17:26 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-03-12 13:17:26 +0000
commit843ce4d87b62e034bb6d089304acbc44016c9383 (patch)
treedee5ccd9723988cb8aa1821c4aea8f12fffcd2c4
parent047cb3e70eebcd2449c2be6c1303a06a0873e1b5 (diff)
downloadrabbitmq-server-843ce4d87b62e034bb6d089304acbc44016c9383.tar.gz
Set the distribution port range to the first of these that matches:
* Not at all if it's mentioned in the config file * $DIST_PORT if that's mentioned in the env file * $RABBITMQ_DIST_PORT if that is set * $RABBITMQ_NODE_PORT + 20000 if that is set * 25672 in all other cases
-rwxr-xr-xscripts/rabbitmq-server30
-rw-r--r--src/rabbit_prelaunch.erl19
2 files changed, 39 insertions, 10 deletions
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index b430eec3..4eb4a83e 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -29,6 +29,10 @@ DEFAULT_NODE_PORT=5672
[ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_IP_ADDRESS=${DEFAULT_NODE_IP_ADDRESS}
[ "x" != "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${DEFAULT_NODE_PORT}
+[ "x" = "x$RABBITMQ_DIST_PORT" ] && RABBITMQ_DIST_PORT=${DIST_PORT}
+[ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${DEFAULT_NODE_PORT} + 20000))
+[ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${RABBITMQ_NODE_PORT} + 20000))
+
[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
[ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS}
[ "x" = "x$RABBITMQ_CONFIG_FILE" ] && RABBITMQ_CONFIG_FILE=${CONFIG_FILE}
@@ -81,16 +85,23 @@ case "$(uname -s)" in
fi
esac
+export RABBITMQ_CONFIG_FILE
+
RABBITMQ_EBIN_ROOT="${RABBITMQ_HOME}/ebin"
-if ! ${ERL_DIR}erl -pa "$RABBITMQ_EBIN_ROOT" \
- -boot "${CLEAN_BOOT_FILE}" \
- -noinput \
- -hidden \
- -s rabbit_prelaunch \
- -sname rabbitmqprelaunch$$ \
- -extra "${RABBITMQ_NODENAME}";
- then
- exit 1;
+ ${ERL_DIR}erl -pa "$RABBITMQ_EBIN_ROOT" \
+ -boot "${CLEAN_BOOT_FILE}" \
+ -noinput \
+ -hidden \
+ -s rabbit_prelaunch \
+ -sname rabbitmqprelaunch$$ \
+ -extra "${RABBITMQ_NODENAME}"
+
+PRELAUNCH_RESULT=$?
+if [ ${PRELAUNCH_RESULT} == 1 ] ; then
+ exit 1
+elif [ ${PRELAUNCH_RESULT} == 0 ] ; then
+ # dist port is not mentioned in the config file, we can set it
+ RABBITMQ_DIST_ARG="-kernel inet_dist_listen_min ${RABBITMQ_DIST_PORT} -kernel inet_dist_listen_max ${RABBITMQ_DIST_PORT}"
fi
RABBITMQ_CONFIG_ARG=
@@ -113,6 +124,7 @@ exec ${ERL_DIR}erl \
+W w \
${RABBITMQ_SERVER_ERL_ARGS} \
${RABBITMQ_LISTEN_ARG} \
+ ${RABBITMQ_DIST_ARG} \
-sasl errlog_type error \
-sasl sasl_error_logger false \
-rabbit error_logger '{file,"'${RABBITMQ_LOGS}'"}' \
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl
index 6e2145ea..0fdb91c4 100644
--- a/src/rabbit_prelaunch.erl
+++ b/src/rabbit_prelaunch.erl
@@ -20,8 +20,9 @@
-include("rabbit.hrl").
--define(BaseApps, [rabbit]).
+-define(DIST_PORT_NOT_CONFIGURED, 0).
-define(ERROR_CODE, 1).
+-define(DIST_PORT_CONFIGURED, 2).
%%----------------------------------------------------------------------------
%% Specs
@@ -63,6 +64,22 @@ duplicate_node_check(NodeStr) ->
io:format(rabbit_nodes:diagnostics([Node]) ++ "~n"),
rabbit_misc:quit(?ERROR_CODE);
false -> ok
+ end,
+ case file:consult(os:getenv("RABBITMQ_CONFIG_FILE") ++ ".config") of
+ {ok, [Config]} ->
+ Kernel = proplists:get_value(kernel, Config, []),
+ case {proplists:get_value(inet_dist_listen_min, Kernel),
+ proplists:get_value(inet_dist_listen_max, Kernel)}
+ of
+ {undefined, undefined} ->
+ rabbit_misc:quit(?DIST_PORT_NOT_CONFIGURED);
+ _ ->
+ rabbit_misc:quit(?DIST_PORT_CONFIGURED)
+ end;
+ {error, _} ->
+ %% TODO can we present errors more nicely here
+ %% than after -config has failed?
+ rabbit_misc:quit(?DIST_PORT_NOT_CONFIGURED)
end;
{error, EpmdReason} ->
io:format("ERROR: epmd error for host ~s: ~s~n",