summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit.erl43
-rw-r--r--src/rabbit_plugins.erl36
2 files changed, 43 insertions, 36 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 13afdc68..87526aae 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -298,28 +298,26 @@ prepare() ->
start() ->
start_it(fun() ->
ok = prepare(),
- ok = rabbit_misc:start_applications(application_load_order())
+ ok = rabbit_misc:start_applications(application_load_order()),
+ ok = print_plugin_info(rabbit_plugins:active_plugins())
end).
start_cold() ->
start_it(fun() ->
ok = prepare(),
- Plugins = determine_required_plugins(),
+ Plugins = rabbit_plugins:bootstrap_envinronment(),
ToBeLoaded = Plugins ++ ?APPS,
io:format("~n"
"Activating RabbitMQ plugins ...~n"),
+ io:format("Plugins: ~p~n", [Plugins]),
load_applications(queue:from_list(ToBeLoaded), sets:new()),
StartupApps =
rabbit_misc:calculate_app_dependency_ordering(ToBeLoaded),
ok = rabbit_misc:start_applications(StartupApps),
-
- io:format("~w plugins activated:~n", [length(Plugins)]),
- [io:format("* ~s-~s~n", [AppName,
- element(2, application:get_key(AppName, vsn))])
- || AppName <- Plugins],
- io:nl()
+
+ ok = print_plugin_info(Plugins)
end).
start_it(StartFun) ->
@@ -586,28 +584,6 @@ insert_default_data() ->
%%---------------------------------------------------------------------------
%% logging
-determine_required_plugins() ->
- {ok, PluginDir} = application:get_env(rabbit, plugins_dir),
- {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
- {ok, EnabledPluginsFile} = application:get_env(rabbit,
- enabled_plugins_file),
- rabbit_plugins:prepare_plugins(EnabledPluginsFile, PluginDir, ExpandDir),
- find_plugins(ExpandDir).
-
-find_plugins(PluginDir) ->
- [prepare_dir_plugin(PluginName) ||
- PluginName <- filelib:wildcard(PluginDir ++ "/*/ebin/*.app")].
-
-prepare_dir_plugin(PluginAppDescFn) ->
- %% Add the plugin ebin directory to the load path
- PluginEBinDirN = filename:dirname(PluginAppDescFn),
- code:add_path(PluginEBinDirN),
-
- %% We want the second-last token
- NameTokens = string:tokens(PluginAppDescFn,"/."),
- PluginNameString = lists:nth(length(NameTokens) - 1, NameTokens),
- list_to_atom(PluginNameString).
-
ensure_working_log_handlers() ->
Handlers = gen_event:which_handlers(error_logger),
ok = ensure_working_log_handler(error_logger_tty_h,
@@ -690,6 +666,13 @@ force_event_refresh() ->
%%---------------------------------------------------------------------------
%% misc
+print_plugin_info(Plugins) ->
+ io:format("~w plugins activated:~n", [length(Plugins)]),
+ [io:format("* ~s-~s~n", [AppName,
+ element(2, application:get_key(AppName, vsn))])
+ || AppName <- Plugins],
+ io:nl().
+
erts_version_check() ->
FoundVer = erlang:system_info(version),
case rabbit_misc:version_compare(?ERTS_MINIMUM, FoundVer, lte) of
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 0a5f8d51..0ab0d3aa 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -17,7 +17,7 @@
-module(rabbit_plugins).
-include("rabbit.hrl").
--export([start/0, stop/0, prepare_plugins/3]).
+-export([start/0, stop/0, bootstrap_envinronment/0, active_plugins/0]).
-define(VERBOSE_OPT, "-v").
-define(MINIMAL_OPT, "-m").
@@ -30,11 +30,8 @@
-spec(start/0 :: () -> no_return()).
-spec(stop/0 :: () -> 'ok').
--spec(find_plugins/1 :: (file:filename()) -> [#plugin{}]).
--spec(read_enabled_plugins/1 :: (file:filename()) -> [atom()]).
--spec(lookup_plugins/2 :: ([atom()], [#plugin{}]) -> [#plugin{}]).
--spec(calculate_required_plugins/2 :: ([atom()], [#plugin{}]) -> [atom()]).
--spec(plugin_names/1 :: ([#plugin{}]) -> [atom()]).
+-spec(bootstrap_envinronment/0 :: () -> [atom()]).
+-spec(active_plugins/0 :: () -> [atom()]).
-endif.
@@ -83,6 +80,23 @@ start() ->
stop() ->
ok.
+bootstrap_envinronment() ->
+ {ok, PluginDir} = application:get_env(rabbit, plugins_dir),
+ {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
+ {ok, EnabledPluginsFile} = application:get_env(rabbit,
+ enabled_plugins_file),
+ prepare_plugins(EnabledPluginsFile, PluginDir, ExpandDir),
+ [prepare_dir_plugin(PluginName) ||
+ PluginName <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")].
+
+active_plugins() ->
+ {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
+ InstalledPlugins = [ P#plugin.name || P <- find_plugins(ExpandDir) ],
+ [App || {App, _, _} <- application:which_applications(),
+ lists:member(App, InstalledPlugins)].
+
+%%----------------------------------------------------------------------------
+
prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) ->
AllPlugins = find_plugins(PluginsDistDir),
Enabled = read_enabled_plugins(EnabledPluginsFile),
@@ -110,6 +124,16 @@ prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) ->
[prepare_plugin(Plugin, DestDir) || Plugin <- ToUnpackPlugins].
+prepare_dir_plugin(PluginAppDescFn) ->
+ %% Add the plugin ebin directory to the load path
+ PluginEBinDirN = filename:dirname(PluginAppDescFn),
+ code:add_path(PluginEBinDirN),
+
+ %% We want the second-last token
+ NameTokens = string:tokens(PluginAppDescFn,"/."),
+ PluginNameString = lists:nth(length(NameTokens) - 1, NameTokens),
+ list_to_atom(PluginNameString).
+
%%----------------------------------------------------------------------------
action(list, [], Opts, PluginsFile, PluginsDir) ->