summaryrefslogtreecommitdiff
path: root/src/rabbit.erl
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-01-22 17:03:45 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-01-24 12:17:43 +0100
commitf5d8d88e728cf08f971ba7acd3567aebc94a91d6 (patch)
tree875fe86ba1709e62dfaa9a3fb9065087206a6258 /src/rabbit.erl
parentf618e7e766bb20ce4e99d9a67751b512b10d64a5 (diff)
downloadrabbitmq-server-git-f5d8d88e728cf08f971ba7acd3567aebc94a91d6.tar.gz
rabbit: Change start_apps/2 to call application:ensure_all_started/2
.. instead of reinventing about the same logic. start_apps/2 is not called to start the `rabbit` application anymore (it is started as a normal Erlang application now). It means it's only used to start plugins which are also supposed to be regular Erlang applications. It runs boot steps unconditionally as well (because this function never starts `rabbit). One difference with the previous code is that the previous code started all loaded applications. This seemed unnecessary and even caused issues with testsuites where some applications were loaded like `rabbitmqctl` but were not meant to be started. Another difference is that before, all boot steps were executed at once, then all plugins were started. Now, to improve consistency and make sure that a dependency is fully ready before a plugin which depends on it starts, for each application we execute the boot steps then start it, before moving to the next. [#170870798]
Diffstat (limited to 'src/rabbit.erl')
-rw-r--r--src/rabbit.erl22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 292272738d..35ffc6ea16 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -599,21 +599,27 @@ start_apps(Apps) ->
-spec start_apps([app_name()],
#{app_name() => restart_type()}) -> 'ok'.
+%% TODO: start_apps/2 and start_loaded_apps/2 are now specific to
+%% plugins. Those function should be moved over `rabbit_plugins`, along
+%% with top_apps/1, once the latter stops using app_utils as well.
+
start_apps(Apps, RestartTypes) ->
app_utils:load_applications(Apps),
ok = rabbit_feature_flags:refresh_feature_flags_after_app_load(Apps),
start_loaded_apps(Apps, RestartTypes).
start_loaded_apps(Apps, RestartTypes) ->
+ false = lists:member(rabbit, Apps), %% Assertion.
rabbit_prelaunch_conf:decrypt_config(Apps),
- OrderedApps = app_utils:app_dependency_order(Apps, false),
- case lists:member(rabbit, Apps) of
- false -> rabbit_boot_steps:run_boot_steps(Apps); %% plugin activation
- true -> ok %% will run during start of rabbit app
- end,
- ok = app_utils:start_applications(OrderedApps,
- handle_app_error(could_not_start),
- RestartTypes).
+ lists:foreach(
+ fun(App) ->
+ RestartType = maps:get(App, RestartTypes, temporary),
+ ok = rabbit_boot_steps:run_boot_steps([App]),
+ case application:ensure_all_started(App, RestartType) of
+ {ok, _} -> ok;
+ {error, Reason} -> throw({could_not_start, App, Reason})
+ end
+ end, Apps).
-spec stop_apps([app_name()]) -> 'ok'.