summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-01-24 11:37:50 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-01-24 11:43:58 +0100
commitba1b6cbbfe24715d98eac5a6c97e199db137c76d (patch)
treed4b9ea9e5e6f23d98a5588e0534b7d9bf9f98a6a
parentdd8262646d208e394844e26edbc1fec47949129d (diff)
downloadrabbitmq-server-git-ba1b6cbbfe24715d98eac5a6c97e199db137c76d.tar.gz
rabbit: Fix plugins' run_boot_steps() vs. start order
Before `rabbit` startup code was rewritten as part of rabbitmq/rabbitmq-server#2180 to make it closer to a regular Erlang application, plugins' boot steps were executed before plugins were started. This commit restores this behavior. Indeed the initial patch inverted them by starting the plugins first, then executed the boot steps. It also brings another improvement in the process: a dependency has its boot steps executed and is started before a plugin which depends on it is considered. This should improve consistency. Note that the `start_apps/2` function, which is run when a user enables a plugin at runtime must be improved as well. There is a work in progress in rabbitmq/rabbitmq-server#2219.
-rw-r--r--src/rabbit.erl18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 7f16d0b1d1..292272738d 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -983,18 +983,28 @@ do_run_postlaunch_phase() ->
rabbit_log_prelaunch:debug("== Plugins =="),
rabbit_log_prelaunch:debug("Setting plugins up"),
+ %% `Plugins` contains all the enabled plugins, plus their
+ %% dependencies. The order is important: dependencies appear
+ %% before plugin which depend on them.
Plugins = rabbit_plugins:setup(),
rabbit_log_prelaunch:debug(
"Starting the following plugins: ~p", [Plugins]),
+ %% We can load all plugins and refresh their feature flags at
+ %% once, because it does not involve running code from the
+ %% plugins.
app_utils:load_applications(Plugins),
ok = rabbit_feature_flags:refresh_feature_flags_after_app_load(
Plugins),
+ %% However, we want to run their boot steps and actually start
+ %% them one by one, to ensure a dependency is fully started
+ %% before a plugin which depends on it gets a chance to start.
lists:foreach(
fun(Plugin) ->
- case application:ensure_all_started(Plugin) of
- {ok, _} -> rabbit_boot_steps:run_boot_steps([Plugin]);
- Error -> throw(Error)
- end
+ ok = rabbit_boot_steps:run_boot_steps([Plugin]),
+ case application:ensure_all_started(Plugin) of
+ {ok, _} -> ok;
+ Error -> throw(Error)
+ end
end, Plugins),
rabbit_log_prelaunch:debug("Marking RabbitMQ as running"),