Skip to content

Commit 989cde8

Browse files
author
Simon MacMullen
committed
Merge branch 'stable'
2 parents 1645f22 + 280de0c commit 989cde8

File tree

2 files changed

+29
-44
lines changed

2 files changed

+29
-44
lines changed

src/rabbit.erl

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,10 @@ start_it(StartFun) ->
351351
false -> StartFun()
352352
end
353353
catch
354-
throw:{could_not_start, rabbit,
355-
boot_failure_already_logged} ->
356-
throw(boot_failure_already_logged),
357-
ok;
358354
throw:{could_not_start, _App, _Reason} = Err ->
359-
boot_error(Err, wrapper, not_available);
355+
boot_error(Err, not_available);
360356
_:Reason ->
361-
boot_error(Reason, wrapper, erlang:get_stacktrace())
357+
boot_error(Reason, erlang:get_stacktrace())
362358
after
363359
unlink(Marker),
364360
Marker ! stop,
@@ -415,7 +411,7 @@ handle_app_error(Term) ->
415411
end.
416412

417413
run_cleanup_steps(Apps) ->
418-
[run_step(Name, Attrs, cleanup) || {_, Name, Attrs} <- find_steps(Apps)],
414+
[run_step(Attrs, cleanup) || Attrs <- find_steps(Apps)],
419415
ok.
420416

421417
await_startup() ->
@@ -543,27 +539,22 @@ run_boot_steps() ->
543539
run_boot_steps([App || {App, _, _} <- application:loaded_applications()]).
544540

545541
run_boot_steps(Apps) ->
546-
[ok = run_step(Step, Attrs, mfa) || {_, Step, Attrs} <- find_steps(Apps)],
542+
[ok = run_step(Attrs, mfa) || Attrs <- find_steps(Apps)],
547543
ok.
548544

549545
find_steps(Apps) ->
550546
All = sort_boot_steps(rabbit_misc:all_module_attributes(rabbit_boot_step)),
551-
[Step || {App, _, _} = Step <- All, lists:member(App, Apps)].
547+
[Attrs || {App, _, Attrs} <- All, lists:member(App, Apps)].
552548

553-
run_step(StepName, Attributes, AttributeName) ->
549+
run_step(Attributes, AttributeName) ->
554550
case [MFA || {Key, MFA} <- Attributes,
555551
Key =:= AttributeName] of
556552
[] ->
557553
ok;
558554
MFAs ->
559-
[try
560-
apply(M,F,A)
561-
of
555+
[case apply(M,F,A) of
562556
ok -> ok;
563-
{error, Reason} -> boot_error(Reason, StepName, not_available)
564-
catch
565-
_:Reason -> boot_error(Reason, StepName,
566-
erlang:get_stacktrace())
557+
{error, Reason} -> exit({error, Reason})
567558
end || {M,F,A} <- MFAs],
568559
ok
569560
end.
@@ -611,10 +602,10 @@ sort_boot_steps(UnsortedSteps) ->
611602
end.
612603

613604
-ifdef(use_specs).
614-
-spec(boot_error/3 :: (term(), atom(), not_available | [tuple()])
615-
-> no_return()).
605+
-spec(boot_error/2 :: (term(), not_available | [tuple()]) -> no_return()).
616606
-endif.
617-
boot_error({error, {timeout_waiting_for_tables, _}}, _Step, _Stacktrace) ->
607+
boot_error({could_not_start, rabbit, {{timeout_waiting_for_tables, _}, _}},
608+
_Stacktrace) ->
618609
AllNodes = rabbit_mnesia:cluster_nodes(all),
619610
{Err, Nodes} =
620611
case AllNodes -- [node()] of
@@ -626,33 +617,29 @@ boot_error({error, {timeout_waiting_for_tables, _}}, _Step, _Stacktrace) ->
626617
Ns}
627618
end,
628619
log_boot_error_and_exit(
620+
timeout_waiting_for_tables,
629621
Err ++ rabbit_nodes:diagnostics(Nodes) ++ "~n~n", []);
630-
boot_error(Reason, Step, Stacktrace) ->
631-
Fmt0 = case Step of
632-
wrapper -> "";
633-
_ -> rabbit_misc:format("Boot step:~n ~p~n~n", [Step])
634-
end,
635-
Fmt = Fmt0 ++
636-
"Error description:~n ~p~n~n"
622+
boot_error(Reason, Stacktrace) ->
623+
Fmt = "Error description:~n ~p~n~n"
637624
"Log files (may contain more information):~n ~s~n ~s~n~n",
638625
Args = [Reason, log_location(kernel), log_location(sasl)],
639-
boot_error1(Fmt, Args, Stacktrace).
626+
boot_error(Reason, Fmt, Args, Stacktrace).
640627

641628
-ifdef(use_specs).
642-
-spec(boot_error1/3 :: (string(), [any()], not_available | [tuple()])
629+
-spec(boot_error/4 :: (term(), string(), [any()], not_available | [tuple()])
643630
-> no_return()).
644631
-endif.
645-
boot_error1(Fmt, Args, not_available) ->
646-
log_boot_error_and_exit(Fmt, Args);
647-
boot_error1(Fmt, Args, Stacktrace) ->
648-
log_boot_error_and_exit(Fmt ++ "Stack trace:~n ~p~n~n",
632+
boot_error(Reason, Fmt, Args, not_available) ->
633+
log_boot_error_and_exit(Reason, Fmt, Args);
634+
boot_error(Reason, Fmt, Args, Stacktrace) ->
635+
log_boot_error_and_exit(Reason, Fmt ++ "Stack trace:~n ~p~n~n",
649636
Args ++ [Stacktrace]).
650637

651-
log_boot_error_and_exit(Format, Args) ->
638+
log_boot_error_and_exit(Reason, Format, Args) ->
652639
io:format("~n~nBOOT FAILED~n===========~n~n" ++ Format, Args),
653640
rabbit_log:info(Format, Args),
654641
timer:sleep(1000),
655-
exit(boot_failure_already_logged).
642+
exit(Reason).
656643

657644
%%---------------------------------------------------------------------------
658645
%% boot step functions

test/src/rabbit_tests.erl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,8 @@ test_log_management_during_startup() ->
786786
ok = case catch control_action(start_app, []) of
787787
ok -> exit({got_success_but_expected_failure,
788788
log_rotation_tty_no_handlers_test});
789-
{badrpc, {'EXIT', {rabbit,failure_during_boot,
790-
{error,{cannot_log_to_tty,
791-
_, not_installed}}}}} -> ok
789+
{badrpc, {'EXIT', {error,
790+
{cannot_log_to_tty, _, not_installed}}}} -> ok
792791
end,
793792

794793
%% fix sasl logging
@@ -815,8 +814,7 @@ test_log_management_during_startup() ->
815814
ok -> exit({got_success_but_expected_failure,
816815
log_rotation_no_write_permission_dir_test});
817816
{badrpc, {'EXIT',
818-
{rabbit, failure_during_boot,
819-
{error, {cannot_log_to_file, _, _}}}}} -> ok
817+
{error, {cannot_log_to_file, _, _}}}} -> ok
820818
end,
821819

822820
%% start application with logging to a subdirectory which
@@ -829,10 +827,10 @@ test_log_management_during_startup() ->
829827
ok -> exit({got_success_but_expected_failure,
830828
log_rotatation_parent_dirs_test});
831829
{badrpc,
832-
{'EXIT', {rabbit,failure_during_boot,
833-
{error, {cannot_log_to_file, _,
834-
{error,
835-
{cannot_create_parent_dirs, _, eacces}}}}}}} -> ok
830+
{'EXIT',
831+
{error, {cannot_log_to_file, _,
832+
{error,
833+
{cannot_create_parent_dirs, _, eacces}}}}}} -> ok
836834
end,
837835
ok = set_permissions(TmpDir, 8#00700),
838836
ok = set_permissions(TmpLog, 8#00600),

0 commit comments

Comments
 (0)