summaryrefslogtreecommitdiff
path: root/src/rabbit.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-02-02 12:54:28 +0000
committerSimon MacMullen <simon@rabbitmq.com>2012-02-02 12:54:28 +0000
commit9b937a1e4ab5d652d2e8221f92ea364725ab94ce (patch)
tree0f2626071d2b6d68fbf4a26206357ace23fae118 /src/rabbit.erl
parent9b6c99384e421f767d3b353ad9f0d793f3072d28 (diff)
parentc23dbf8d0e309d295c09fb2d283b57e3d2ca8730 (diff)
downloadrabbitmq-server-git-9b937a1e4ab5d652d2e8221f92ea364725ab94ce.tar.gz
Merge in default
Diffstat (limited to 'src/rabbit.erl')
-rw-r--r--src/rabbit.erl45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 3dcd49386f..01ca2302f4 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -22,7 +22,7 @@
status/0, is_running/0, is_running/1, environment/0,
rotate_logs/1, force_event_refresh/0]).
--export([start/2, stop/1]).
+-export([start/2, stop/1, diagnostics/1]).
-export([log_location/1]). %% for testing
@@ -236,6 +236,7 @@
{'required',[any(),...]}}} |
{'ok',pid()}).
-spec(stop/1 :: (_) -> 'ok').
+-spec(diagnostics/1 :: ([node()]) -> string()).
-endif.
@@ -360,12 +361,11 @@ rotate_logs(BinarySuffix) ->
start(normal, []) ->
case erts_version_check() of
ok ->
- ok = rabbit_mnesia:delete_previously_running_nodes(),
{ok, SupPid} = rabbit_sup:start_link(),
true = register(rabbit, self()),
-
print_banner(),
[ok = run_boot_step(Step) || Step <- boot_steps()],
+ ok = rabbit_mnesia:delete_previously_running_nodes(),
io:format("~nbroker running~n"),
{ok, SupPid};
Error ->
@@ -501,6 +501,17 @@ sort_boot_steps(UnsortedSteps) ->
end])
end.
+boot_step_error({error, {timeout_waiting_for_tables, _}}, _Stacktrace) ->
+ {Err, Nodes} =
+ case rabbit_mnesia:read_previously_running_nodes() of
+ [] -> {"Timeout waiting for tables.~n"
+ "Diagnostics for all cluster nodes follow:~n",
+ rabbit_mnesia:all_clustered_nodes()};
+ Ns -> {format("Timeout waiting for tables from nodes: ~p.~n"
+ "Diagnostics for these nodes follow:~n", [Ns]), Ns}
+ end,
+ boot_error(Err ++ diagnostics(Nodes) ++ "~n~n", []);
+
boot_step_error(Reason, Stacktrace) ->
boot_error("Error description:~n ~p~n~n"
"Log files (may contain more information):~n ~s~n ~s~n~n"
@@ -513,6 +524,34 @@ boot_error(Format, Args) ->
timer:sleep(1000),
exit({?MODULE, failure_during_boot}).
+diagnostics(Nodes) ->
+ 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),
+ [{"~ndiagnostics for node ~s:", [Node]},
+ case net_adm:names(NodeHost) of
+ {error, EpmdReason} ->
+ {"- unable to connect to epmd on ~s: ~w",
+ [NodeHost, EpmdReason]};
+ {ok, NamePorts} ->
+ {"- nodes and their ports on ~s: ~p",
+ [NodeHost, [{list_to_atom(Name), Port} ||
+ {Name, Port} <- NamePorts]]}
+ end].
+
+format(F, A) -> binary_to_list(iolist_to_binary(io_lib:format(F, A))).
+
%%---------------------------------------------------------------------------
%% boot step functions