summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Watson <watson.timothy@gmail.com>2014-02-28 10:02:34 +0000
committerTim Watson <watson.timothy@gmail.com>2014-02-28 10:02:34 +0000
commitc3e63dbe92ce947e3c0c8d63de0a38d4c3ca4cce (patch)
tree34e8cf974b1188f3c8ca40daae6729061cfafc36 /src
parent41477f4c37db75e85fd19830fbc3fbed7bb3a13a (diff)
downloadrabbitmq-server-git-c3e63dbe92ce947e3c0c8d63de0a38d4c3ca4cce.tar.gz
Fix plugin expansion during runtime configuration changes
Blowing away the plugin expand directory when we make runtime changes is wrong and we don't need to strip away expanded plugins when they're disabled, since the directory is cleaned on each restart and leaving the files in place isn't an issue.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_plugins.erl31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 6fe4c12788..1799570d15 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -38,20 +38,27 @@
%%----------------------------------------------------------------------------
-enable(Plugins) ->
- setup(),
- rabbit_boot:start(Plugins).
+enable(Enabled) ->
+ prepare_plugins(Enabled),
+ rabbit_boot:start(Enabled).
disable(Plugins) ->
- setup(),
rabbit_boot:stop(Plugins).
%% @doc Prepares the file system and installs all enabled plugins.
setup() ->
- {ok, PluginDir} = application:get_env(rabbit, plugins_dir),
{ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
+
+ %% Eliminate the contents of the destination directory
+ case delete_recursively(ExpandDir) of
+ ok -> ok;
+ {error, E1} -> throw({error, {cannot_delete_plugins_expand_dir,
+ [ExpandDir, E1]}})
+ end,
+
{ok, EnabledFile} = application:get_env(rabbit, enabled_plugins_file),
- prepare_plugins(EnabledFile, PluginDir, ExpandDir).
+ Enabled = read_enabled(EnabledFile),
+ prepare_plugins(Enabled).
%% @doc Lists the plugins which are currently running.
active() ->
@@ -114,9 +121,11 @@ dependencies(Reverse, Sources, AllPlugins) ->
%%----------------------------------------------------------------------------
-prepare_plugins(EnabledFile, PluginsDistDir, ExpandDir) ->
+prepare_plugins(Enabled) ->
+ {ok, PluginsDistDir} = application:get_env(rabbit, plugins_dir),
+ {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
+
AllPlugins = list(PluginsDistDir),
- Enabled = read_enabled(EnabledFile),
ToUnpack = dependencies(false, Enabled, AllPlugins),
ToUnpackPlugins = lookup_plugins(ToUnpack, AllPlugins),
@@ -127,12 +136,6 @@ prepare_plugins(EnabledFile, PluginsDistDir, ExpandDir) ->
[Missing])
end,
- %% Eliminate the contents of the destination directory
- case delete_recursively(ExpandDir) of
- ok -> ok;
- {error, E1} -> throw({error, {cannot_delete_plugins_expand_dir,
- [ExpandDir, E1]}})
- end,
case filelib:ensure_dir(ExpandDir ++ "/") of
ok -> ok;
{error, E2} -> throw({error, {cannot_create_plugins_expand_dir,