diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-06-05 19:14:27 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-06-05 19:14:27 +0100 |
commit | 3469d0d272f11a00d8af0405bfca2d6c8c2d8fa0 (patch) | |
tree | 719f2844b9fe679485e7214939f0d4a95f60ead1 /src/rabbit_plugins.erl | |
parent | c57a0236fc2ec7cdd96f5abd7a3f18d1e4282a59 (diff) | |
download | rabbitmq-server-3469d0d272f11a00d8af0405bfca2d6c8c2d8fa0.tar.gz |
Rewrite the changes to rabbit_plugins_main/enable,disable. Now we just change the plugins file exactly as we do on default, then contact the server and say "I want you to be running this". This has cut out quite a lot of code, and I am pretty sure fixed some bugs.
Diffstat (limited to 'src/rabbit_plugins.erl')
-rw-r--r-- | src/rabbit_plugins.erl | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 2dffa669..e139eed4 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -18,7 +18,7 @@ -include("rabbit.hrl"). -export([setup/0, active/0, read_enabled/1, list/1, dependencies/3]). --export([enable/1, disable/1]). +-export([ensure/1]). %%---------------------------------------------------------------------------- @@ -32,26 +32,24 @@ -spec(read_enabled/1 :: (file:filename()) -> [plugin_name()]). -spec(dependencies/3 :: (boolean(), [plugin_name()], [#plugin{}]) -> [plugin_name()]). --spec(enable/1 :: ([plugin_name()]) -> 'ok'). --spec(disable/1 :: ([plugin_name()]) -> 'ok'). +-spec(ensure/1 :: ([plugin_name()]) -> {'ok', [atom()], [atom()]}). -endif. %%---------------------------------------------------------------------------- -enable(Plugins) -> - prepare_plugins(Plugins), - rabbit:start_apps(Plugins), - ok = rabbit_event:notify(plugins_changed, [{enabled, Plugins}]). - -disable(Plugins) -> - RunningApps = rabbit_misc:which_applications(), - ToDisable = [P || P <- Plugins, - proplists:is_defined(P, RunningApps)], +ensure(Wanted) -> + Current = active(), + Start = Wanted -- Current, + Stop = Current -- Wanted, + prepare_plugins(Start), %% We need sync_notify here since mgmt will attempt to look at all %% the modules for the disabled plugins - if they are unloaded %% that won't work. - ok = rabbit_event:sync_notify(plugins_changed, [{disabled, ToDisable}]), - rabbit:stop_apps(ToDisable). + ok = rabbit_event:notify(plugins_changed, [{enabled, Start}, + {disabled, Stop}]), + rabbit:start_apps(Start), + rabbit:stop_apps(Stop), + {ok, Start, Stop}. %% @doc Prepares the file system and installs all enabled plugins. setup() -> |