diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-12-16 17:00:40 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-12-16 17:00:40 +0000 |
| commit | c23dbf8d0e309d295c09fb2d283b57e3d2ca8730 (patch) | |
| tree | 20aca8ea1544cd5d9ffb1eff7c6735b6fafc985e /src/rabbit.erl | |
| parent | 86fa04997da714453d0a3f0aff83d8524514241a (diff) | |
| download | rabbitmq-server-git-c23dbf8d0e309d295c09fb2d283b57e3d2ca8730.tar.gz | |
Make rabbit:diagnostics/1 just return a string. It's still most convenient to assemble it the way we did before, but now the API is saner.
Diffstat (limited to 'src/rabbit.erl')
| -rw-r--r-- | src/rabbit.erl | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index bcc4dfdebc..8e747b7a26 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -235,7 +235,7 @@ {'required',[any(),...]}}} | {'ok',pid()}). -spec(stop/1 :: (_) -> 'ok'). --spec(diagnostics/1 :: ([node()]) -> [{string(), [any()]}]). +-spec(diagnostics/1 :: ([node()]) -> string()). -endif. @@ -490,19 +490,15 @@ sort_boot_steps(UnsortedSteps) -> end. boot_failed({error, {timeout_waiting_for_tables, _}}, _Stacktrace) -> - {Fmt0, Args0, Nodes} = + {Err, Nodes} = case rabbit_mnesia:read_previously_running_nodes() of [] -> {"Timeout waiting for tables.~n" - "Diagnostics for all cluster nodes follow:~n", [], + "Diagnostics for all cluster nodes follow:~n", rabbit_mnesia:all_clustered_nodes()}; - Ns -> {"Timeout waiting for tables from nodes: ~p.~n" - "Diagnostics for these nodes follow:~n", [Ns], Ns} + Ns -> {format("Timeout waiting for tables from nodes: ~p.~n" + "Diagnostics for these nodes follow:~n", [Ns]), Ns} end, - {Fmt, Args} = lists:foldl( - fun({F, A}, {Fmt1, Args1}) -> - {Fmt1 ++ "~n" ++ F, Args1 ++ A} - end, {[], []}, [{Fmt0, Args0} | diagnostics(Nodes)]), - boot_error(Fmt ++ "~n~n", Args); + boot_error(Err ++ diagnostics(Nodes) ++ "~n~n", []); boot_failed(Reason, Stacktrace) -> boot_error("FAILED~nReason: ~p~nStacktrace: ~p~n", [Reason, Stacktrace]). @@ -514,17 +510,21 @@ boot_error(Format, Args) -> exit({?MODULE, failure_during_boot}). diagnostics(Nodes) -> - lists:flatten([diagnostics_node(Node) || Node <- Nodes]) ++ - [{"- current node: ~w", [node()]}, - case init:get_argument(home) of - {ok, [[Home]]} -> {"- current node home dir: ~s", [Home]}; - Other -> {"- no current node home dir: ~p", [Other]} - end, - {"- current node cookie hash: ~s", [rabbit_misc:cookie_hash()]}]. + lists:foldl(fun({F, A}, Str) -> Str ++ format(F ++ "~n", A) end, "", + lists:flatten([diagnostics_node(Node) || Node <- Nodes]) ++ + diagnostics0()). + +diagnostics0() -> + [{"- current node: ~w", [node()]}, + case init:get_argument(home) of + {ok, [[Home]]} -> {"- current node home dir: ~s", [Home]}; + Other -> {"- no current node home dir: ~p", [Other]} + end, + {"- current node cookie hash: ~s", [rabbit_misc:cookie_hash()]}]. diagnostics_node(Node) -> {_NodeName, NodeHost} = rabbit_misc:nodeparts(Node), - [{"diagnostics for node ~s:", [Node]}, + [{"~ndiagnostics for node ~s:", [Node]}, case net_adm:names(NodeHost) of {error, EpmdReason} -> {"- unable to connect to epmd on ~s: ~w", @@ -535,6 +535,8 @@ diagnostics_node(Node) -> {Name, Port} <- NamePorts]]} end]. +format(F, A) -> binary_to_list(iolist_to_binary(io_lib:format(F, A))). + %%--------------------------------------------------------------------------- %% boot step functions |
