Skip to content

Commit 90fa013

Browse files
dumbbelllukebakken
authored andcommitted
rabbit: Run plugins' boot steps during rabbit start/2
This restores the behavior prior the commit making `rabbit` closer to a standard Erlang application. Plugins are still actually started after rabbit is started (because they depend on the `rabbit` application). Only the execution of their boot steps was moved earlier. With the behavior restored, it also means that a plugin's dependencies are not started yet when its boot steps are executed.
1 parent e3bbdfe commit 90fa013

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

deps/rabbit/src/rabbit.erl

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,29 @@ start(normal, []) ->
870870
log_banner(),
871871
warn_if_kernel_config_dubious(),
872872
warn_if_disc_io_options_dubious(),
873-
%% We run `rabbit` boot steps only for now. Plugins boot steps
874-
%% will be executed as part of the postlaunch phase after they
875-
%% are started.
876-
rabbit_boot_steps:run_boot_steps([rabbit]),
877-
run_postlaunch_phase(),
873+
874+
rabbit_log_prelaunch:debug(""),
875+
rabbit_log_prelaunch:debug("== Plugins (prelaunch phase) =="),
876+
877+
rabbit_log_prelaunch:debug("Setting plugins up"),
878+
%% `Plugins` contains all the enabled plugins, plus their
879+
%% dependencies. The order is important: dependencies appear
880+
%% before plugin which depend on them.
881+
Plugins = rabbit_plugins:setup(),
882+
rabbit_log_prelaunch:debug(
883+
"Loading the following plugins: ~p", [Plugins]),
884+
%% We can load all plugins and refresh their feature flags at
885+
%% once, because it does not involve running code from the
886+
%% plugins.
887+
app_utils:load_applications(Plugins),
888+
ok = rabbit_feature_flags:refresh_feature_flags_after_app_load(
889+
Plugins),
890+
891+
rabbit_log_prelaunch:debug(""),
892+
rabbit_log_prelaunch:debug("== Boot steps =="),
893+
894+
ok = rabbit_boot_steps:run_boot_steps([rabbit | Plugins]),
895+
run_postlaunch_phase(Plugins),
878896
{ok, SupPid}
879897
catch
880898
throw:{error, _} = Error ->
@@ -893,45 +911,34 @@ start(normal, []) ->
893911
Error
894912
end.
895913

896-
run_postlaunch_phase() ->
897-
spawn(fun() -> do_run_postlaunch_phase() end).
914+
run_postlaunch_phase(Plugins) ->
915+
spawn(fun() -> do_run_postlaunch_phase(Plugins) end).
898916

899-
do_run_postlaunch_phase() ->
917+
do_run_postlaunch_phase(Plugins) ->
900918
%% Once RabbitMQ itself is started, we need to run a few more steps,
901919
%% in particular start plugins.
902920
rabbit_log_prelaunch:debug(""),
903921
rabbit_log_prelaunch:debug("== Postlaunch phase =="),
904922

905923
try
906924
rabbit_log_prelaunch:debug(""),
907-
rabbit_log_prelaunch:debug("== Plugins =="),
925+
rabbit_log_prelaunch:debug("== Plugins (postlaunch phase) =="),
908926

909-
rabbit_log_prelaunch:debug("Setting plugins up"),
910-
%% `Plugins` contains all the enabled plugins, plus their
911-
%% dependencies. The order is important: dependencies appear
912-
%% before plugin which depend on them.
913-
Plugins = rabbit_plugins:setup(),
914-
rabbit_log_prelaunch:debug(
915-
"Starting the following plugins: ~p", [Plugins]),
916-
%% We can load all plugins and refresh their feature flags at
917-
%% once, because it does not involve running code from the
918-
%% plugins.
919-
app_utils:load_applications(Plugins),
920-
ok = rabbit_feature_flags:refresh_feature_flags_after_app_load(
921-
Plugins),
922927
%% However, we want to run their boot steps and actually start
923928
%% them one by one, to ensure a dependency is fully started
924929
%% before a plugin which depends on it gets a chance to start.
930+
rabbit_log_prelaunch:debug(
931+
"Starting the following plugins: ~p", [Plugins]),
925932
lists:foreach(
926933
fun(Plugin) ->
927-
ok = rabbit_boot_steps:run_boot_steps([Plugin]),
928934
case application:ensure_all_started(Plugin) of
929935
{ok, _} -> ok;
930936
Error -> throw(Error)
931937
end
932938
end, Plugins),
933939

934940
%% Successful boot resets node maintenance state.
941+
rabbit_log_prelaunch:debug(""),
935942
rabbit_log_prelaunch:info("Resetting node maintenance status"),
936943
_ = rabbit_maintenance:unmark_as_being_drained(),
937944

0 commit comments

Comments
 (0)