summaryrefslogtreecommitdiff
path: root/src/rabbit.erl
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-09-26 14:06:10 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-09-26 14:06:10 +0100
commite15ac86a20f4daa235587b4fd8ca2fa663ac8804 (patch)
tree788103ba155053ffcf141406492a64585d2f376c /src/rabbit.erl
parent732b7b8dafc1126570cc686b2b8a14f73dcdaa64 (diff)
parentb77710749b536980d7530680c6605830047b8ab1 (diff)
downloadrabbitmq-server-git-e15ac86a20f4daa235587b4fd8ca2fa663ac8804.tar.gz
merge default into bug25179
Diffstat (limited to 'src/rabbit.erl')
-rw-r--r--src/rabbit.erl42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index afa97ddc86..7b417b00c6 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -303,7 +303,8 @@ start() ->
ok = rabbit_node_monitor:prepare_cluster_status_files(),
ok = rabbit_mnesia:check_cluster_consistency(),
ok = ensure_working_log_handlers(),
- ok = app_utils:start_applications(app_startup_order()),
+ ok = app_utils:start_applications(
+ app_startup_order(), fun handle_app_error/2),
ok = print_plugin_info(rabbit_plugins:active())
end).
@@ -323,10 +324,17 @@ boot() ->
ok = app_utils:load_applications(ToBeLoaded),
StartupApps = app_utils:app_dependency_order(ToBeLoaded,
false),
- ok = app_utils:start_applications(StartupApps),
+ ok = app_utils:start_applications(
+ StartupApps, fun handle_app_error/2),
ok = print_plugin_info(Plugins)
end).
+handle_app_error(App, {bad_return, {_MFA, {'EXIT', {Reason, _}}}}) ->
+ boot_error({could_not_start, App, Reason}, not_available);
+
+handle_app_error(App, Reason) ->
+ boot_error({could_not_start, App, Reason}, not_available).
+
start_it(StartFun) ->
try
StartFun()
@@ -450,7 +458,7 @@ run_boot_step({StepName, Attributes}) ->
[try
apply(M,F,A)
catch
- _:Reason -> boot_step_error(Reason, erlang:get_stacktrace())
+ _:Reason -> boot_error(Reason, erlang:get_stacktrace())
end || {M,F,A} <- MFAs],
io:format("done~n"),
ok
@@ -489,14 +497,14 @@ sort_boot_steps(UnsortedSteps) ->
{mfa, {M,F,A}} <- Attributes,
not erlang:function_exported(M, F, length(A))] of
[] -> SortedSteps;
- MissingFunctions -> boot_error(
+ MissingFunctions -> basic_boot_error(
"Boot step functions not exported: ~p~n",
[MissingFunctions])
end;
{error, {vertex, duplicate, StepName}} ->
- boot_error("Duplicate boot step name: ~w~n", [StepName]);
+ basic_boot_error("Duplicate boot step name: ~w~n", [StepName]);
{error, {edge, Reason, From, To}} ->
- boot_error(
+ basic_boot_error(
"Could not add boot step dependency of ~w on ~w:~n~s",
[To, From,
case Reason of
@@ -510,7 +518,7 @@ sort_boot_steps(UnsortedSteps) ->
end])
end.
-boot_step_error({error, {timeout_waiting_for_tables, _}}, _Stacktrace) ->
+boot_error({error, {timeout_waiting_for_tables, _}}, _Stacktrace) ->
AllNodes = rabbit_mnesia:cluster_nodes(all),
{Err, Nodes} =
case AllNodes -- [node()] of
@@ -521,15 +529,19 @@ boot_step_error({error, {timeout_waiting_for_tables, _}}, _Stacktrace) ->
"Timeout contacting cluster nodes: ~p.~n", [Ns]),
Ns}
end,
- boot_error(Err ++ rabbit_nodes: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"
- "Stack trace:~n ~p~n~n",
- [Reason, log_location(kernel), log_location(sasl), Stacktrace]).
+ basic_boot_error(Err ++ rabbit_nodes:diagnostics(Nodes) ++ "~n~n", []);
+
+boot_error(Reason, Stacktrace) ->
+ Fmt = "Error description:~n ~p~n~n"
+ "Log files (may contain more information):~n ~s~n ~s~n~n",
+ Args = [Reason, log_location(kernel), log_location(sasl)],
+ case Stacktrace of
+ not_available -> basic_boot_error(Fmt, Args);
+ _ -> basic_boot_error(Fmt ++ "Stack trace:~n ~p~n~n",
+ Args ++ [Stacktrace])
+ end.
-boot_error(Format, Args) ->
+basic_boot_error(Format, Args) ->
io:format("~n~nBOOT FAILED~n===========~n~n" ++ Format, Args),
error_logger:error_msg(Format, Args),
timer:sleep(1000),