summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert@lshift.net>2008-09-10 10:53:55 +0100
committerHubert Plociniczak <hubert@lshift.net>2008-09-10 10:53:55 +0100
commitdf440897a77b4350cc5bc73e38aaeacc910fb0cf (patch)
tree4329cf3cc9d6ea992151040efd81801b0eb270c8 /src
parent36e824bf5148ef1121a58de2408da8c8751501c7 (diff)
downloadrabbitmq-server-git-df440897a77b4350cc5bc73e38aaeacc910fb0cf.tar.gz
Use lists:foreach instead of tail recursion
in rotate_logs command. Updated usage function() Reverted change in rabbitmq-server.spec that didn't belong to this bug.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_multi.erl31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index 8a6bfbe05e..bf1d2d99a5 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -69,9 +69,9 @@ usage() ->
Available commands:
- start_all <NodeCount> - start a local cluster of RabbitMQ nodes.
- stop_all - stops all local RabbitMQ nodes.
- rotate_logs_all [Suffix] - rotate logs for all local RabbitMQ nodes.
+ start_all <NodeCount> - start a local cluster of RabbitMQ nodes.
+ stop_all - stops all local RabbitMQ nodes.
+ rotate_logs [Suffix] - rotate logs for all local and running RabbitMQ nodes.
"),
halt(3).
@@ -99,10 +99,18 @@ action(rotate_logs, [], RpcTimeout) ->
action(rotate_logs, [Suffix], RpcTimeout) ->
io:format("Rotating logs for all nodes...~n", []),
- call_all_nodes(fun(NodePids) ->
- rotate_logs(NodePids,
- list_to_binary(Suffix),
- RpcTimeout) end).
+ BinarySuffix = list_to_binary(Suffix),
+ call_all_nodes(
+ fun(NodePids) ->
+ lists:foreach(fun ({Node, _}) ->
+ io:format("Rotating logs for node ~p", [Node]),
+ case rpc:call(Node, rabbit, rotate_logs,
+ [BinarySuffix], RpcTimeout) of
+ {badrpc, Error} -> io:format(": ~p.~n", [Error]);
+ ok -> io:format(": ok.~n", [])
+ end
+ end, NodePids)
+ end).
%% PNodePid is the list of PIDs
%% Running is a boolean exhibiting success at some moment
@@ -281,15 +289,6 @@ is_dead(Pid) ->
end
end}]).
-rotate_logs([], _, _) -> ok;
-rotate_logs([{Node, _} | Rest], BinarySuffix, RpcTimeout) ->
- io:format("Rotating logs for node ~p", [Node]),
- case rpc:call(Node, rabbit, rotate_logs, [BinarySuffix], RpcTimeout) of
- {badrpc, Error} -> io:format(": ~p.~n", [Error]);
- ok -> io:format(": ok.~n", [])
- end,
- rotate_logs(Rest, BinarySuffix, RpcTimeout).
-
call_all_nodes(Func) ->
case read_pids_file() of
[] -> throw(no_nodes_running);