@@ -528,10 +528,9 @@ handle_app_error(Term) ->
528528is_booting () -> is_booting (node ()).
529529
530530is_booting (Node ) when Node =:= node () ->
531- case rabbit_boot_state :get () of
532- booting -> true ;
533- _ -> false
534- end ;
531+ rabbit_boot_state :has_reached_and_is_active (booting )
532+ andalso
533+ not rabbit_boot_state :has_reached (ready );
535534is_booting (Node ) ->
536535 case rpc :call (Node , rabbit , is_booting , []) of
537536 {badrpc , _ } = Err -> Err ;
@@ -856,11 +855,30 @@ start(normal, []) ->
856855 log_banner (),
857856 warn_if_kernel_config_dubious (),
858857 warn_if_disc_io_options_dubious (),
859- % % We run `rabbit` boot steps only for now. Plugins boot steps
860- % % will be executed as part of the postlaunch phase after they
861- % % are started.
862- rabbit_boot_steps :run_boot_steps ([rabbit ]),
863- run_postlaunch_phase (),
858+
859+ rabbit_log_prelaunch :debug (" " ),
860+ rabbit_log_prelaunch :debug (" == Plugins (prelaunch phase) ==" ),
861+
862+ rabbit_log_prelaunch :debug (" Setting plugins up" ),
863+ % % `Plugins` contains all the enabled plugins, plus their
864+ % % dependencies. The order is important: dependencies appear
865+ % % before plugin which depend on them.
866+ Plugins = rabbit_plugins :setup (),
867+ rabbit_log_prelaunch :debug (
868+ " Loading the following plugins: ~p " , [Plugins ]),
869+ % % We can load all plugins and refresh their feature flags at
870+ % % once, because it does not involve running code from the
871+ % % plugins.
872+ ok = app_utils :load_applications (Plugins ),
873+ ok = rabbit_feature_flags :refresh_feature_flags_after_app_load (
874+ Plugins ),
875+
876+ rabbit_log_prelaunch :debug (" " ),
877+ rabbit_log_prelaunch :debug (" == Boot steps ==" ),
878+
879+ ok = rabbit_boot_steps :run_boot_steps ([rabbit | Plugins ]),
880+ run_postlaunch_phase (Plugins ),
881+ rabbit_boot_state :set (core_started ),
864882 {ok , SupPid }
865883 catch
866884 throw :{error , _ } = Error ->
@@ -879,46 +897,39 @@ start(normal, []) ->
879897 Error
880898 end .
881899
882- run_postlaunch_phase () ->
883- spawn (fun () -> do_run_postlaunch_phase () end ).
900+ run_postlaunch_phase (Plugins ) ->
901+ spawn (fun () -> do_run_postlaunch_phase (Plugins ) end ).
884902
885- do_run_postlaunch_phase () ->
903+ do_run_postlaunch_phase (Plugins ) ->
886904 % % Once RabbitMQ itself is started, we need to run a few more steps,
887905 % % in particular start plugins.
888906 rabbit_log_prelaunch :debug (" " ),
889907 rabbit_log_prelaunch :debug (" == Postlaunch phase ==" ),
890908
891909 try
910+ % % Successful boot resets node maintenance state.
892911 rabbit_log_prelaunch :debug (" " ),
893- rabbit_log_prelaunch :debug (" == Plugins ==" ),
912+ rabbit_log_prelaunch :info (" Resetting node maintenance status" ),
913+ _ = rabbit_maintenance :unmark_as_being_drained (),
914+
915+ rabbit_log_prelaunch :debug (" " ),
916+ rabbit_log_prelaunch :debug (" == Plugins (postlaunch phase) ==" ),
894917
895- rabbit_log_prelaunch :debug (" Setting plugins up" ),
896- % % `Plugins` contains all the enabled plugins, plus their
897- % % dependencies. The order is important: dependencies appear
898- % % before plugin which depend on them.
899- Plugins = rabbit_plugins :setup (),
900- rabbit_log_prelaunch :debug (
901- " Starting the following plugins: ~p " , [Plugins ]),
902- % % We can load all plugins and refresh their feature flags at
903- % % once, because it does not involve running code from the
904- % % plugins.
905- app_utils :load_applications (Plugins ),
906- ok = rabbit_feature_flags :refresh_feature_flags_after_app_load (
907- Plugins ),
908918 % % However, we want to run their boot steps and actually start
909919 % % them one by one, to ensure a dependency is fully started
910920 % % before a plugin which depends on it gets a chance to start.
921+ rabbit_log_prelaunch :debug (
922+ " Starting the following plugins: ~p " , [Plugins ]),
911923 lists :foreach (
912924 fun (Plugin ) ->
913- ok = rabbit_boot_steps :run_boot_steps ([Plugin ]),
914925 case application :ensure_all_started (Plugin ) of
915926 {ok , _ } -> ok ;
916927 Error -> throw (Error )
917928 end
918929 end , Plugins ),
919930
920931 % % Export definitions after all plugins have been enabled,
921- % % see rabbitmq/rabbitmq-server#2384
932+ % % see rabbitmq/rabbitmq-server#2384.
922933 case rabbit_definitions :maybe_load_definitions () of
923934 ok -> ok ;
924935 DefLoadError -> throw (DefLoadError )
@@ -933,8 +944,9 @@ do_run_postlaunch_phase() ->
933944 % % The node is ready: mark it as such and log it.
934945 % % NOTE: PLEASE DO NOT ADD CRITICAL NODE STARTUP CODE AFTER THIS.
935946 ok = rabbit_lager :broker_is_started (),
936- ok = log_broker_started (
937- rabbit_plugins :strictly_plugins (rabbit_plugins :active ())),
947+ ActivePlugins = rabbit_plugins :active (),
948+ StrictlyPlugins = rabbit_plugins :strictly_plugins (ActivePlugins ),
949+ ok = log_broker_started (StrictlyPlugins ),
938950
939951 rabbit_log_prelaunch :info (" Resetting node maintenance status" ),
940952 % % successful boot resets node maintenance state
0 commit comments