diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-02-02 12:54:28 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-02-02 12:54:28 +0000 |
commit | 02ff8e736031fbd0fd6b5928d1fa01458429a107 (patch) | |
tree | 0f2626071d2b6d68fbf4a26206357ace23fae118 | |
parent | eca129d8b936472c5c3dd280feca40fcb8d2e3bd (diff) | |
parent | eda932b35ff58c6ffd9b46522ad33380915c3d4a (diff) | |
download | rabbitmq-server-02ff8e736031fbd0fd6b5928d1fa01458429a107.tar.gz |
Merge in default
-rw-r--r-- | src/rabbit.erl | 45 | ||||
-rw-r--r-- | src/rabbit_control.erl | 24 | ||||
-rw-r--r-- | src/rabbit_mnesia.erl | 2 | ||||
-rw-r--r-- | src/rabbit_prelaunch.erl | 3 |
4 files changed, 46 insertions, 28 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 3dcd4938..01ca2302 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 diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index 22b57b1a..b31661b3 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]). +-export([start/0, stop/0, action/5]). -define(RPC_TIMEOUT, infinity). -define(EXTERNAL_CHECK_INTERVAL, 1000). @@ -49,7 +49,6 @@ (atom(), node(), [string()], [{string(), any()}], fun ((string(), [any()]) -> 'ok')) -> 'ok'). --spec(diagnostics/1 :: (node()) -> [{string(), [any()]}]). -spec(usage/0 :: () -> no_return()). -endif. @@ -143,26 +142,7 @@ print_report0(Node, {Module, InfoFun, KeysFun}, VHostArg) -> print_error(Format, Args) -> fmt_stderr("Error: " ++ Format, Args). print_badrpc_diagnostics(Node) -> - [fmt_stderr(Fmt, Args) || {Fmt, Args} <- diagnostics(Node)]. - -diagnostics(Node) -> - {_NodeName, NodeHost} = rabbit_misc:nodeparts(Node), - [{"diagnostics:", []}, - 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, - {"- 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()]}]. + fmt_stderr(rabbit:diagnostics([Node]), []). stop() -> ok. diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 0f33a38a..4999fc30 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -712,7 +712,7 @@ wait_for_replicated_tables() -> wait_for_tables(replicated_table_names()). wait_for_tables() -> wait_for_tables(table_names()). wait_for_tables(TableNames) -> - case mnesia:wait_for_tables(TableNames, 30000) of + case mnesia:wait_for_tables(TableNames, 3000) of ok -> ok; {timeout, BadTabs} -> diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl index 50444dc4..5fc67662 100644 --- a/src/rabbit_prelaunch.erl +++ b/src/rabbit_prelaunch.erl @@ -252,8 +252,7 @@ duplicate_node_check(NodeStr) -> true -> io:format("node with name ~p " "already running on ~p~n", [NodeName, NodeHost]), - [io:format(Fmt ++ "~n", Args) || - {Fmt, Args} <- rabbit_control:diagnostics(Node)], + io:format(rabbit:diagnostics([Node]) ++ "~n"), terminate(?ERROR_CODE); false -> ok end; |