summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Kuch <jerryk@vmware.com>2011-09-13 09:17:09 -0700
committerJerry Kuch <jerryk@vmware.com>2011-09-13 09:17:09 -0700
commit98ff0baab78e942aa9b3f73fd10f21724971abb2 (patch)
treedebbcf02264160507e642952279663523fe1edc0
parentf2412e2f4af51dcdb8c5998595ba49e42979cb77 (diff)
parent6a5a56ea911e68f739f2759139c4dc0a93230cba (diff)
downloadrabbitmq-server-98ff0baab78e942aa9b3f73fd10f21724971abb2.tar.gz
Merge bug 23056
-rw-r--r--Makefile2
-rw-r--r--docs/rabbitmqctl.1.xml8
-rw-r--r--packaging/RPMS/Fedora/rabbitmq-server.spec8
-rw-r--r--packaging/common/rabbitmq-server.init19
-rwxr-xr-xpackaging/common/rabbitmq-server.ocf23
-rw-r--r--packaging/debs/Debian/debian/changelog12
-rw-r--r--packaging/debs/Debian/debian/dirs1
-rw-r--r--packaging/debs/Debian/debian/postinst1
-rw-r--r--packaging/debs/Debian/debian/postrm.in3
-rw-r--r--scripts/rabbitmq-service.bat1
-rw-r--r--src/gen_server2.erl4
-rw-r--r--src/rabbit.erl15
-rw-r--r--src/rabbit_basic.erl74
-rw-r--r--src/rabbit_control.erl31
-rw-r--r--src/rabbit_direct.erl2
-rw-r--r--src/rabbit_misc.erl8
-rw-r--r--src/rabbit_prelaunch.erl36
-rw-r--r--src/rabbit_tests.erl13
-rw-r--r--src/rabbit_upgrade.erl8
19 files changed, 139 insertions, 130 deletions
diff --git a/Makefile b/Makefile
index ee2700af..5cea016e 100644
--- a/Makefile
+++ b/Makefile
@@ -121,7 +121,7 @@ $(SOURCE_DIR)/rabbit_framing_amqp_0_8.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_c
$(PYTHON) codegen.py body $(AMQP_SPEC_JSON_FILES_0_8) $@
dialyze: $(BEAM_TARGETS) $(BASIC_PLT)
- dialyzer --plt $(BASIC_PLT) --no_native \
+ dialyzer --plt $(BASIC_PLT) --no_native --fullpath \
-Wrace_conditions $(BEAM_TARGETS)
# rabbit.plt is used by rabbitmq-erlang-client's dialyze make target
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml
index 4d3065b7..3291c44d 100644
--- a/docs/rabbitmqctl.1.xml
+++ b/docs/rabbitmqctl.1.xml
@@ -556,13 +556,15 @@
<varlistentry>
<term><cmdsynopsis><command>list_users</command></cmdsynopsis></term>
<listitem>
- <para>Lists users</para>
+ <para>
+ Lists users. Each result row will contain the user name
+ followed by a list of the tags set for that user.
+ </para>
<para role="example-prefix">For example:</para>
<screen role="example">rabbitmqctl list_users</screen>
<para role="example">
This command instructs the RabbitMQ broker to list all
- users. Each result row will contain the user name and
- the administrator status of the user, in that order.
+ users.
</para>
</listitem>
</varlistentry>
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec
index bdd6c4a1..0c5aa96a 100644
--- a/packaging/RPMS/Fedora/rabbitmq-server.spec
+++ b/packaging/RPMS/Fedora/rabbitmq-server.spec
@@ -50,7 +50,6 @@ make install TARGET_DIR=%{_maindir} \
mkdir -p %{buildroot}%{_localstatedir}/lib/rabbitmq/mnesia
mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq
-mkdir -p %{buildroot}%{_localstatedir}/run/rabbitmq
#Copy all necessary lib files etc.
install -p -D -m 0755 %{S:1} %{buildroot}%{_initrddir}/rabbitmq-server
@@ -112,7 +111,6 @@ done
%defattr(-,root,root,-)
%attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/lib/rabbitmq
%attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/log/rabbitmq
-%attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/run/rabbitmq
%dir %{_sysconfdir}/rabbitmq
%{_initrddir}/rabbitmq-server
%config(noreplace) %{_sysconfdir}/logrotate.d/rabbitmq-server
@@ -122,6 +120,12 @@ done
rm -rf %{buildroot}
%changelog
+* Fri Sep 9 2011 tim@rabbitmq.com 2.6.1-1
+- New Upstream Release
+
+* Fri Aug 26 2011 tim@rabbitmq.com 2.6.0-1
+- New Upstream Release
+
* Mon Jun 27 2011 simon@rabbitmq.com 2.5.1-1
- New Upstream Release
diff --git a/packaging/common/rabbitmq-server.init b/packaging/common/rabbitmq-server.init
index e2815f04..15fd5d5b 100644
--- a/packaging/common/rabbitmq-server.init
+++ b/packaging/common/rabbitmq-server.init
@@ -34,12 +34,27 @@ test -x $CONTROL || exit 0
RETVAL=0
set -e
+ensure_pid_dir () {
+ PID_DIR=`dirname ${PID_FILE}`
+ if [ ! -d ${PID_DIR} ] ; then
+ mkdir -p ${PID_DIR}
+ chown -R ${USER}:${USER} ${PID_DIR}
+ chmod 755 ${PID_DIR}
+ fi
+}
+
+remove_pid () {
+ rm -f ${PID_FILE}
+ rmdir `dirname ${PID_FILE}` || :
+}
+
start_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
echo RabbitMQ is currently running
else
RETVAL=0
+ ensure_pid_dir
set +e
setsid sh -c "RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \
${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err" &
@@ -54,7 +69,7 @@ start_rabbitmq () {
fi
;;
*)
- rm -f $PID_FILE
+ remove_pid
echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
RETVAL=1
;;
@@ -70,7 +85,7 @@ stop_rabbitmq () {
RETVAL=$?
set -e
if [ $RETVAL = 0 ] ; then
- rm -f $PID_FILE
+ remove_pid
if [ -n "$LOCK_FILE" ] ; then
rm -f $LOCK_FILE
fi
diff --git a/packaging/common/rabbitmq-server.ocf b/packaging/common/rabbitmq-server.ocf
index 51e16517..e6776eff 100755
--- a/packaging/common/rabbitmq-server.ocf
+++ b/packaging/common/rabbitmq-server.ocf
@@ -43,7 +43,7 @@ OCF_RESKEY_server_default="/usr/sbin/rabbitmq-server"
OCF_RESKEY_ctl_default="/usr/sbin/rabbitmqctl"
OCF_RESKEY_nodename_default="rabbit@localhost"
OCF_RESKEY_log_base_default="/var/log/rabbitmq"
-OCF_RESKEY_pid_file_default="/var/lib/rabbitmq/pid"
+OCF_RESKEY_pid_file_default="/var/run/rabbitmq/pid"
: ${OCF_RESKEY_server=${OCF_RESKEY_server_default}}
: ${OCF_RESKEY_ctl=${OCF_RESKEY_ctl_default}}
: ${OCF_RESKEY_nodename=${OCF_RESKEY_nodename_default}}
@@ -179,6 +179,21 @@ RABBITMQ_PID_FILE=$OCF_RESKEY_pid_file
[ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME"
[ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME
+ensure_pid_dir () {
+ PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
+ if [ ! -d ${PID_DIR} ] ; then
+ mkdir -p ${PID_DIR}
+ chown -R rabbitmq:rabbitmq ${PID_DIR}
+ chmod 755 ${PID_DIR}
+ fi
+ return $OCF_SUCCESS
+}
+
+remove_pid () {
+ rm -f ${RABBITMQ_PID_FILE}
+ rmdir `dirname ${RABBITMQ_PID_FILE}` || :
+}
+
export_vars() {
[ ! -z $RABBITMQ_NODE_IP_ADDRESS ] && export RABBITMQ_NODE_IP_ADDRESS
[ ! -z $RABBITMQ_NODE_PORT ] && export RABBITMQ_NODE_PORT
@@ -186,7 +201,7 @@ export_vars() {
[ ! -z $RABBITMQ_LOG_BASE ] && export RABBITMQ_LOG_BASE
[ ! -z $RABBITMQ_MNESIA_BASE ] && export RABBITMQ_MNESIA_BASE
[ ! -z $RABBITMQ_SERVER_START_ARGS ] && export RABBITMQ_SERVER_START_ARGS
- [ ! -z $RABBITMQ_PID_FILE ] && export RABBITMQ_PID_FILE
+ [ ! -z $RABBITMQ_PID_FILE ] && ensure_pid_dir && export RABBITMQ_PID_FILE
}
rabbit_validate_partial() {
@@ -268,7 +283,7 @@ rabbit_start() {
rabbit_wait $RABBITMQ_PID_FILE
rc=$?
if [ "$rc" != $OCF_SUCCESS ]; then
- rm -f $RABBITMQ_PID_FILE
+ remove_pid
ocf_log info "rabbitmq-server start failed: $rc"
exit $OCF_ERR_GENERIC
fi
@@ -299,7 +314,7 @@ rabbit_stop() {
rabbit_status
rc=$?
if [ "$rc" = $OCF_NOT_RUNNING ]; then
- rm -f $RABBITMQ_PID_FILE
+ remove_pid
stop_wait=0
break
elif [ "$rc" != $OCF_SUCCESS ]; then
diff --git a/packaging/debs/Debian/debian/changelog b/packaging/debs/Debian/debian/changelog
index 9063a6ed..8f526544 100644
--- a/packaging/debs/Debian/debian/changelog
+++ b/packaging/debs/Debian/debian/changelog
@@ -1,3 +1,15 @@
+rabbitmq-server (2.6.1-1) natty; urgency=low
+
+ * New Upstream Release
+
+ -- Tim <tim@rabbitmq.com> Fri, 09 Sep 2011 14:38:45 +0100
+
+rabbitmq-server (2.6.0-1) natty; urgency=low
+
+ * New Upstream Release
+
+ -- Tim <tim@rabbitmq.com> Fri, 26 Aug 2011 16:29:40 +0100
+
rabbitmq-server (2.5.1-1) lucid; urgency=low
* New Upstream Release
diff --git a/packaging/debs/Debian/debian/dirs b/packaging/debs/Debian/debian/dirs
index 5cf167d5..625b7d41 100644
--- a/packaging/debs/Debian/debian/dirs
+++ b/packaging/debs/Debian/debian/dirs
@@ -4,7 +4,6 @@ usr/sbin
usr/share/man
var/lib/rabbitmq/mnesia
var/log/rabbitmq
-var/run/rabbitmq
etc/logrotate.d
etc/rabbitmq
diff --git a/packaging/debs/Debian/debian/postinst b/packaging/debs/Debian/debian/postinst
index ca531f14..b11340ef 100644
--- a/packaging/debs/Debian/debian/postinst
+++ b/packaging/debs/Debian/debian/postinst
@@ -32,7 +32,6 @@ fi
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
-chown -R rabbitmq:rabbitmq /var/run/rabbitmq
case "$1" in
configure)
diff --git a/packaging/debs/Debian/debian/postrm.in b/packaging/debs/Debian/debian/postrm.in
index c4aeeebe..baf081fc 100644
--- a/packaging/debs/Debian/debian/postrm.in
+++ b/packaging/debs/Debian/debian/postrm.in
@@ -32,9 +32,6 @@ case "$1" in
if [ -d /var/log/rabbitmq ]; then
rm -r /var/log/rabbitmq
fi
- if [ -d /var/run/rabbitmq ]; then
- rm -r /var/run/rabbitmq
- fi
if [ -d /etc/rabbitmq ]; then
rm -r /etc/rabbitmq
fi
diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat
index b2aa4f58..7de7a716 100644
--- a/scripts/rabbitmq-service.bat
+++ b/scripts/rabbitmq-service.bat
@@ -204,6 +204,7 @@ set ERLANG_SERVICE_ARGUMENTS= ^
-s rabbit ^
+W w ^
+A30 ^
++P 1048576 ^
-kernel inet_default_connect_options "[{nodelay,true}]" ^
!RABBITMQ_LISTEN_ARG! ^
-kernel error_logger {file,\""!LOGS:\=/!"\"} ^
diff --git a/src/gen_server2.erl b/src/gen_server2.erl
index 35258139..ab6c4e64 100644
--- a/src/gen_server2.erl
+++ b/src/gen_server2.erl
@@ -616,11 +616,11 @@ in(Input, Priority, GS2State = #gs2_state { queue = Queue }) ->
process_msg({system, From, Req},
GS2State = #gs2_state { parent = Parent, debug = Debug }) ->
+ %% gen_server puts Hib on the end as the 7th arg, but that version
+ %% of the fun seems not to be documented so leaving out for now.
sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug, GS2State);
process_msg({'EXIT', Parent, Reason} = Msg,
GS2State = #gs2_state { parent = Parent }) ->
- %% gen_server puts Hib on the end as the 7th arg, but that version
- %% of the fun seems not to be documented so leaving out for now.
terminate(Reason, Msg, GS2State);
process_msg(Msg, GS2State = #gs2_state { debug = [] }) ->
handle_msg(Msg, GS2State);
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 20b3e275..3e311747 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -18,7 +18,8 @@
-behaviour(application).
--export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0, environment/0,
+-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0,
+ is_running/0 , is_running/1, environment/0,
rotate_logs/1, force_event_refresh/0]).
-export([start/2, stop/1]).
@@ -196,6 +197,8 @@
{os, {atom(), atom()}} |
{erlang_version, string()} |
{memory, any()}]).
+-spec(is_running/0 :: () -> boolean()).
+-spec(is_running/1 :: (node()) -> boolean()).
-spec(environment/0 :: () -> [{atom() | term()}]).
-spec(log_location/1 :: ('sasl' | 'kernel') -> log_location()).
@@ -241,11 +244,19 @@ stop_and_halt() ->
status() ->
[{pid, list_to_integer(os:getpid())},
- {running_applications, application:which_applications()},
+ {running_applications, application:which_applications(infinity)},
{os, os:type()},
{erlang_version, erlang:system_info(system_version)},
{memory, erlang:memory()}].
+is_running() -> is_running(node()).
+
+is_running(Node) ->
+ case rpc:call(Node, application, which_applications, [infinity]) of
+ {badrpc, _} -> false;
+ Apps -> proplists:is_defined(rabbit, Apps)
+ end.
+
environment() ->
lists:keysort(
1, [P || P = {K, _} <- application:get_all_env(rabbit),
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index 9cc406e7..b266d366 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -18,8 +18,8 @@
-include("rabbit.hrl").
-include("rabbit_framing.hrl").
--export([publish/1, message/3, message/4, properties/1, delivery/4]).
--export([publish/4, publish/6]).
+-export([publish/4, publish/6, publish/1,
+ message/3, message/4, properties/1, delivery/4]).
-export([build_content/2, from_content/1]).
%%----------------------------------------------------------------------------
@@ -35,6 +35,12 @@
-type(exchange_input() :: (rabbit_types:exchange() | rabbit_exchange:name())).
-type(body_input() :: (binary() | [binary()])).
+-spec(publish/4 ::
+ (exchange_input(), rabbit_router:routing_key(), properties_input(),
+ body_input()) -> publish_result()).
+-spec(publish/6 ::
+ (exchange_input(), rabbit_router:routing_key(), boolean(), boolean(),
+ properties_input(), body_input()) -> publish_result()).
-spec(publish/1 ::
(rabbit_types:delivery()) -> publish_result()).
-spec(delivery/4 ::
@@ -49,12 +55,6 @@
rabbit_types:ok_or_error2(rabbit_types:message(), any())).
-spec(properties/1 ::
(properties_input()) -> rabbit_framing:amqp_property_record()).
--spec(publish/4 ::
- (exchange_input(), rabbit_router:routing_key(), properties_input(),
- body_input()) -> publish_result()).
--spec(publish/6 ::
- (exchange_input(), rabbit_router:routing_key(), boolean(), boolean(),
- properties_input(), body_input()) -> publish_result()).
-spec(build_content/2 :: (rabbit_framing:amqp_property_record(),
binary() | [binary()]) -> rabbit_types:content()).
-spec(from_content/1 :: (rabbit_types:content()) ->
@@ -64,13 +64,34 @@
%%----------------------------------------------------------------------------
+%% Convenience function, for avoiding round-trips in calls across the
+%% erlang distributed network.
+publish(Exchange, RoutingKeyBin, Properties, Body) ->
+ publish(Exchange, RoutingKeyBin, false, false, Properties, Body).
+
+%% Convenience function, for avoiding round-trips in calls across the
+%% erlang distributed network.
+publish(X = #exchange{name = XName}, RKey, Mandatory, Immediate, Props, Body) ->
+ publish(X, delivery(Mandatory, Immediate,
+ message(XName, RKey, properties(Props), Body),
+ undefined));
+publish(XName, RKey, Mandatory, Immediate, Props, Body) ->
+ publish(delivery(Mandatory, Immediate,
+ message(XName, RKey, properties(Props), Body),
+ undefined)).
+
publish(Delivery = #delivery{
- message = #basic_message{exchange_name = ExchangeName}}) ->
- case rabbit_exchange:lookup(ExchangeName) of
+ message = #basic_message{exchange_name = XName}}) ->
+ case rabbit_exchange:lookup(XName) of
{ok, X} -> publish(X, Delivery);
- Other -> Other
+ Err -> Err
end.
+publish(X, Delivery) ->
+ {RoutingRes, DeliveredQPids} =
+ rabbit_router:deliver(rabbit_exchange:route(X, Delivery), Delivery),
+ {ok, RoutingRes, DeliveredQPids}.
+
delivery(Mandatory, Immediate, Message, MsgSeqNo) ->
#delivery{mandatory = Mandatory, immediate = Immediate, sender = self(),
message = Message, msg_seq_no = MsgSeqNo}.
@@ -113,11 +134,10 @@ strip_header(#content{properties = Props = #'P_basic'{headers = Headers}}
headers = Headers0}})
end.
-message(ExchangeName, RoutingKey,
- #content{properties = Props} = DecodedContent) ->
+message(XName, RoutingKey, #content{properties = Props} = DecodedContent) ->
try
{ok, #basic_message{
- exchange_name = ExchangeName,
+ exchange_name = XName,
content = strip_header(DecodedContent, ?DELETED_HEADER),
id = rabbit_guid:guid(),
is_persistent = is_message_persistent(DecodedContent),
@@ -127,10 +147,10 @@ message(ExchangeName, RoutingKey,
{error, _Reason} = Error -> Error
end.
-message(ExchangeName, RoutingKey, RawProperties, Body) ->
+message(XName, RoutingKey, RawProperties, Body) ->
Properties = properties(RawProperties),
Content = build_content(Properties, Body),
- {ok, Msg} = message(ExchangeName, RoutingKey, Content),
+ {ok, Msg} = message(XName, RoutingKey, Content),
Msg.
properties(P = #'P_basic'{}) ->
@@ -152,28 +172,6 @@ indexof([], _Element, _N) -> 0;
indexof([Element | _Rest], Element, N) -> N;
indexof([_ | Rest], Element, N) -> indexof(Rest, Element, N + 1).
-%% Convenience function, for avoiding round-trips in calls across the
-%% erlang distributed network.
-publish(Exchange, RoutingKeyBin, Properties, Body) ->
- publish(Exchange, RoutingKeyBin, false, false, Properties, Body).
-
-%% Convenience function, for avoiding round-trips in calls across the
-%% erlang distributed network.
-publish(X = #exchange{name = XName}, RKey, Mandatory, Immediate, Props, Body) ->
- publish(X, delivery(Mandatory, Immediate,
- message(XName, RKey, properties(Props), Body),
- undefined));
-publish(XName, RKey, Mandatory, Immediate, Props, Body) ->
- case rabbit_exchange:lookup(XName) of
- {ok, X} -> publish(X, RKey, Mandatory, Immediate, Props, Body);
- Err -> Err
- end.
-
-publish(X, Delivery) ->
- {RoutingRes, DeliveredQPids} =
- rabbit_router:deliver(rabbit_exchange:route(X, Delivery), Delivery),
- {ok, RoutingRes, DeliveredQPids}.
-
is_message_persistent(#content{properties = #'P_basic'{
delivery_mode = Mode}}) ->
case Mode of
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index b9e550c9..1163ae9d 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -17,7 +17,7 @@
-module(rabbit_control).
-include("rabbit.hrl").
--export([start/0, stop/0, action/5, diagnostics/1, log_action/3]).
+-export([start/0, stop/0, action/5, diagnostics/1]).
-define(RPC_TIMEOUT, infinity).
@@ -50,7 +50,6 @@
-> 'ok').
-spec(diagnostics/1 :: (node()) -> [{string(), [any()]}]).
-spec(usage/0 :: () -> no_return()).
--spec(log_action/3 :: (node(), string(), [term()]) -> ok).
-endif.
@@ -73,7 +72,6 @@ start() ->
Command = list_to_atom(Command0),
Quiet = proplists:get_bool(?QUIET_OPT, Opts1),
Node = proplists:get_value(?NODE_OPT, Opts1),
- rpc_call(Node, rabbit_control, log_action, [node(), Command0, Args]),
Inform = case Quiet of
true -> fun (_Format, _Args1) -> ok end;
false -> fun (Format, Args1) ->
@@ -362,7 +360,7 @@ wait_for_application(Node, PidFile, Inform) ->
wait_for_application(Node, Pid) ->
case process_up(Pid) of
- true -> case node_up(Node) of
+ true -> case rabbit:is_running(Node) of
true -> ok;
false -> timer:sleep(1000),
wait_for_application(Node, Pid)
@@ -378,12 +376,6 @@ wait_and_read_pid_file(PidFile) ->
{error, _} = E -> exit({error, {could_not_read_pid, E}})
end.
-node_up(Node) ->
- case rpc_call(Node, application, which_applications, [infinity]) of
- {badrpc, _} -> false;
- Apps -> proplists:is_defined(rabbit, Apps)
- end.
-
% Test using some OS clunkiness since we shouldn't trust
% rpc:call(os, getpid, []) at this point
process_up(Pid) ->
@@ -521,22 +513,3 @@ quit(Status) ->
{unix, _} -> halt(Status);
{win32, _} -> init:stop(Status)
end.
-
-log_action(Node, Command, Args) ->
- rabbit_misc:with_local_io(
- fun () ->
- error_logger:info_msg("~p executing~n rabbitmqctl ~s ~s~n",
- [Node, Command,
- format_args(mask_args(Command, Args))])
- end).
-
-%% Mask passwords and other sensitive info before logging.
-mask_args("add_user", [Name, _Password | Args]) ->
- [Name, "****" | Args];
-mask_args("change_password", [Name, _Password | Args]) ->
- [Name, "****" | Args];
-mask_args(_, Args) ->
- Args.
-
-format_args(Args) ->
- string:join([io_lib:format("~p", [A]) || A <- Args], " ").
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index 68afaf5d..6f9a4650 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -72,7 +72,7 @@ list() ->
%%----------------------------------------------------------------------------
connect(Username, VHost, Protocol, Pid, Infos) ->
- case lists:keymember(rabbit, 1, application:which_applications()) of
+ case rabbit:is_running() of
true ->
case rabbit_access_control:check_user_login(Username, []) of
{ok, User} ->
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index ae28722a..0b39a209 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -749,7 +749,7 @@ recursive_delete(Files) ->
end, ok, Files).
recursive_delete1(Path) ->
- case filelib:is_dir(Path) of
+ case filelib:is_dir(Path) and not(is_symlink(Path)) of
false -> case file:delete(Path) of
ok -> ok;
{error, enoent} -> ok; %% Path doesn't exist anyway
@@ -777,6 +777,12 @@ recursive_delete1(Path) ->
end
end.
+is_symlink(Name) ->
+ case file:read_link(Name) of
+ {ok, _} -> true;
+ _ -> false
+ end.
+
recursive_copy(Src, Dest) ->
case filelib:is_dir(Src) of
false -> case file:copy(Src, Dest) of
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl
index e3cf8ebe..9fe073d9 100644
--- a/src/rabbit_prelaunch.erl
+++ b/src/rabbit_prelaunch.erl
@@ -139,38 +139,10 @@ determine_version(App) ->
{App, Vsn}.
delete_recursively(Fn) ->
- case filelib:is_dir(Fn) and not(is_symlink(Fn)) of
- true ->
- case file:list_dir(Fn) of
- {ok, Files} ->
- case lists:foldl(fun ( Fn1, ok) -> delete_recursively(
- Fn ++ "/" ++ Fn1);
- (_Fn1, Err) -> Err
- end, ok, Files) of
- ok -> case file:del_dir(Fn) of
- ok -> ok;
- {error, E} -> {error,
- {cannot_delete, Fn, E}}
- end;
- Err -> Err
- end;
- {error, E} ->
- {error, {cannot_list_files, Fn, E}}
- end;
- false ->
- case filelib:is_file(Fn) of
- true -> case file:delete(Fn) of
- ok -> ok;
- {error, E} -> {error, {cannot_delete, Fn, E}}
- end;
- false -> ok
- end
- end.
-
-is_symlink(Name) ->
- case file:read_link(Name) of
- {ok, _} -> true;
- _ -> false
+ case rabbit_misc:recursive_delete([Fn]) of
+ ok -> ok;
+ {error, {Path, E}} -> {error, {cannot_delete, Path, E}};
+ Error -> Error
end.
unpack_ez_plugins(SrcDir, DestDir) ->
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index cd5d9be0..7e84251f 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -757,13 +757,23 @@ test_topic_expect_match(X, List) ->
end, List).
test_app_management() ->
- %% starting, stopping, status
+ control_action(wait, [rabbit_mnesia:dir() ++ ".pid"]),
+ %% Starting, stopping and diagnostics. Note that we don't try
+ %% 'report' when the rabbit app is stopped and that we enable
+ %% tracing for the duration of this function.
+ ok = control_action(trace_on, []),
ok = control_action(stop_app, []),
ok = control_action(stop_app, []),
ok = control_action(status, []),
+ ok = control_action(cluster_status, []),
+ ok = control_action(environment, []),
ok = control_action(start_app, []),
ok = control_action(start_app, []),
ok = control_action(status, []),
+ ok = control_action(report, []),
+ ok = control_action(cluster_status, []),
+ ok = control_action(environment, []),
+ ok = control_action(trace_off, []),
passed.
test_log_management() ->
@@ -1146,6 +1156,7 @@ test_user_management() ->
ok = control_action(add_user, ["foo", "bar"]),
{error, {user_already_exists, _}} =
control_action(add_user, ["foo", "bar"]),
+ ok = control_action(clear_password, ["foo"]),
ok = control_action(change_password, ["foo", "baz"]),
TestTags = fun (Tags) ->
diff --git a/src/rabbit_upgrade.erl b/src/rabbit_upgrade.erl
index 9739f6b7..e7a302f8 100644
--- a/src/rabbit_upgrade.erl
+++ b/src/rabbit_upgrade.erl
@@ -228,13 +228,7 @@ secondary_upgrade(AllNodes) ->
ok.
nodes_running(Nodes) ->
- [N || N <- Nodes, node_running(N)].
-
-node_running(Node) ->
- case rpc:call(Node, application, which_applications, []) of
- {badrpc, _} -> false;
- Apps -> lists:keysearch(rabbit, 1, Apps) =/= false
- end.
+ [N || N <- Nodes, rabbit:is_running(N)].
%% -------------------------------------------------------------------