@@ -351,10 +351,14 @@ start_it(StartFun) ->
351351 false -> StartFun ()
352352 end
353353 catch
354- throw :{could_not_start , _App , _Reason }= Err ->
355- boot_error (Err , not_available );
354+ throw :{could_not_start , rabbit ,
355+ boot_failure_already_logged } ->
356+ throw (boot_failure_already_logged ),
357+ ok ;
358+ throw :{could_not_start , _App , _Reason } = Err ->
359+ boot_error (Err , wrapper , not_available );
356360 _ :Reason ->
357- boot_error (Reason , erlang :get_stacktrace ())
361+ boot_error (Reason , wrapper , erlang :get_stacktrace ())
358362 after
359363 unlink (Marker ),
360364 Marker ! stop ,
@@ -404,7 +408,7 @@ stop_apps(Apps) ->
404408 ok .
405409
406410handle_app_error (Term ) ->
407- fun (App , {bad_return , {_MFA , {'EXIT' , { ExitReason , _ } }}}) ->
411+ fun (App , {bad_return , {_MFA , {'EXIT' , ExitReason }}}) ->
408412 throw ({Term , App , ExitReason });
409413 (App , Reason ) ->
410414 throw ({Term , App , Reason })
@@ -556,10 +560,9 @@ run_step(StepName, Attributes, AttributeName) ->
556560 apply (M ,F ,A )
557561 of
558562 ok -> ok ;
559- {error , Reason } -> boot_error ({boot_step , StepName , Reason },
560- not_available )
563+ {error , Reason } -> boot_error (Reason , StepName , not_available )
561564 catch
562- _ :Reason -> boot_error ({ boot_step , StepName , Reason } ,
565+ _ :Reason -> boot_error (Reason , StepName ,
563566 erlang :get_stacktrace ())
564567 end || {M ,F ,A } <- MFAs ],
565568 ok
@@ -598,35 +601,20 @@ sort_boot_steps(UnsortedSteps) ->
598601 {_App , StepName , Attributes } <- SortedSteps ,
599602 {mfa , {M ,F ,A }} <- Attributes ,
600603 not erlang :function_exported (M , F , length (A ))] of
601- [] -> SortedSteps ;
602- MissingFunctions -> basic_boot_error (
603- {missing_functions , MissingFunctions },
604- " Boot step functions not exported: ~p~n " ,
605- [MissingFunctions ])
604+ [] -> SortedSteps ;
605+ MissingFns -> exit ({boot_functions_not_exported , MissingFns })
606606 end ;
607607 {error , {vertex , duplicate , StepName }} ->
608- basic_boot_error ({duplicate_boot_step , StepName },
609- " Duplicate boot step name: ~w~n " , [StepName ]);
608+ exit ({duplicate_boot_step , StepName });
610609 {error , {edge , Reason , From , To }} ->
611- basic_boot_error (
612- {invalid_boot_step_dependency , From , To },
613- " Could not add boot step dependency of ~w on ~w :~n~s " ,
614- [To , From ,
615- case Reason of
616- {bad_vertex , V } ->
617- io_lib :format (" Boot step not registered: ~w~n " , [V ]);
618- {bad_edge , [First | Rest ]} ->
619- [io_lib :format (" Cyclic dependency: ~w " , [First ]),
620- [io_lib :format (" depends on ~w " , [Next ]) ||
621- Next <- Rest ],
622- io_lib :format (" depends on ~w~n " , [First ])]
623- end ])
610+ exit ({invalid_boot_step_dependency , From , To , Reason })
624611 end .
625612
626613-ifdef (use_specs ).
627- -spec (boot_error / 2 :: (term (), not_available | [tuple ()]) -> no_return ()).
614+ -spec (boot_error / 3 :: (term (), atom (), not_available | [tuple ()])
615+ -> no_return ()).
628616-endif .
629- boot_error (Term = {error , {timeout_waiting_for_tables , _ }}, _Stacktrace ) ->
617+ boot_error ({error , {timeout_waiting_for_tables , _ }}, _Step , _Stacktrace ) ->
630618 AllNodes = rabbit_mnesia :cluster_nodes (all ),
631619 {Err , Nodes } =
632620 case AllNodes -- [node ()] of
@@ -637,29 +625,34 @@ boot_error(Term={error, {timeout_waiting_for_tables, _}}, _Stacktrace) ->
637625 " Timeout contacting cluster nodes: ~p .~n " , [Ns ]),
638626 Ns }
639627 end ,
640- basic_boot_error (Term ,
641- Err ++ rabbit_nodes :diagnostics (Nodes ) ++ " ~n~n " , []);
642- boot_error (Reason , Stacktrace ) ->
643- Fmt = " Error description:~n ~p~n~n " ++
628+ log_boot_error_and_exit (
629+ 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 "
644637 " Log files (may contain more information):~n ~s~n ~s~n~n " ,
645638 Args = [Reason , log_location (kernel ), log_location (sasl )],
646- boot_error ( Reason , Fmt , Args , Stacktrace ).
639+ boot_error1 ( Fmt , Args , Stacktrace ).
647640
648641-ifdef (use_specs ).
649- -spec (boot_error / 4 :: (term (), string (), [any ()], not_available | [tuple ()])
642+ -spec (boot_error1 / 3 :: (string (), [any ()], not_available | [tuple ()])
650643 -> no_return ()).
651644-endif .
652- boot_error ( Reason , Fmt , Args , not_available ) ->
653- basic_boot_error ( Reason , Fmt , Args );
654- boot_error ( Reason , Fmt , Args , Stacktrace ) ->
655- basic_boot_error ( Reason , Fmt ++ " Stack trace:~n ~p~n~n " ,
656- Args ++ [Stacktrace ]).
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 " ,
649+ Args ++ [Stacktrace ]).
657650
658- basic_boot_error ( Reason , Format , Args ) ->
651+ log_boot_error_and_exit ( Format , Args ) ->
659652 io :format (" ~n~n BOOT FAILED~n ===========~n~n " ++ Format , Args ),
660653 rabbit_log :info (Format , Args ),
661654 timer :sleep (1000 ),
662- exit ({ ? MODULE , failure_during_boot , Reason } ).
655+ exit (boot_failure_already_logged ).
663656
664657% %---------------------------------------------------------------------------
665658% % boot step functions
0 commit comments