diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-06-18 17:08:35 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-06-18 17:08:35 +0100 |
commit | e8b72084734d980b267ee41d39197436d4a0efe2 (patch) | |
tree | 114f9896f92e9c696d1f9dd3a68cd96da7f749a9 | |
parent | fa3340d617df22264808a634342590ece73bcb61 (diff) | |
download | rabbitmq-server-e8b72084734d980b267ee41d39197436d4a0efe2.tar.gz |
rabbitmq-plugins set.
-rw-r--r-- | docs/rabbitmq-plugins.1.xml | 64 | ||||
-rw-r--r-- | src/rabbit_plugins_main.erl | 22 |
2 files changed, 70 insertions, 16 deletions
diff --git a/docs/rabbitmq-plugins.1.xml b/docs/rabbitmq-plugins.1.xml index e891969f..fb5f8e27 100644 --- a/docs/rabbitmq-plugins.1.xml +++ b/docs/rabbitmq-plugins.1.xml @@ -63,6 +63,16 @@ enabled. Implicitly enabled plugins are automatically disabled again when they are no longer required. </para> + + <para> + The <command>enable</command>, <command>disable</command> and + <command>set</command> commands will update the plugins file and + then attempt to connect to the broker and ensure it is running + all enabled plugins. By default if it is not possible to connect + to the running broker (for example if it is stopped) then a + warning is displayed. Specify <command>--online</command> or + <command>--offline</command> to change this behaviour. + </para> </refsect1> <refsect1> @@ -150,14 +160,7 @@ </varlistentry> </variablelist> <para> - Enables the specified plugins and all their - dependencies. This will update the enabled plugins file - and then attempt to connect to the broker and ensure it is - running all enabled plugins. By default if it is not - possible to connect to the running broker (for example if - it is stopped) then a warning is displayed. Specify - <command>--online</command> or - <command>--offline</command> to change this. + Enables the specified plugins and all their dependencies. </para> <para role="example-prefix">For example:</para> @@ -188,14 +191,7 @@ </varlistentry> </variablelist> <para> - Disables the specified plugins and all their - dependencies. This will update the enabled plugins file - and then attempt to connect to the broker and ensure it is - running all enabled plugins. By default if it is not - possible to connect to the running broker (for example if - it is stopped) then a warning is displayed. Specify - <command>--online</command> or - <command>--offline</command> to change this. + Disables the specified plugins and all their dependencies. </para> <para role="example-prefix">For example:</para> @@ -206,6 +202,42 @@ </para> </listitem> </varlistentry> + + <varlistentry> + <term><cmdsynopsis><command>set</command> <arg choice="opt">--offline</arg> <arg choice="opt">--online</arg> <arg choice="req"><replaceable>plugin</replaceable> ...</arg></cmdsynopsis></term> + <listitem> + <variablelist> + <varlistentry> + <term>--offline</term> + <listitem><para>Just modify the enabled plugins file.</para></listitem> + </varlistentry> + <varlistentry> + <term>--online</term> + <listitem><para>Treat failure to connect to the running broker as fatal.</para></listitem> + </varlistentry> + <varlistentry> + <term>plugin</term> + <listitem><para>Zero or more plugins to enable.</para></listitem> + </varlistentry> + </variablelist> + <para> + Enables the specified plugins and all their + dependencies. Unlike <command>rabbitmq-plugins + enable</command> this command ignores and overwrites any + existing plugin configuration. <command>rabbitmq-plugins + set</command> with no plugin arguments is a legal command + meaning "disable all plugins". + </para> + + <para role="example-prefix">For example:</para> + <screen role="example">rabbitmq-plugins set rabbitmq_management</screen> + <para role="example"> + This command enables the <command>management</command> + plugin and its dependencies and disables everything else. + </para> + </listitem> + </varlistentry> + </variablelist> </refsect1> diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index a3f12c96..7e9c4d60 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -44,6 +44,7 @@ [{list, [?VERBOSE_DEF, ?MINIMAL_DEF, ?ENABLED_DEF, ?ENABLED_ALL_DEF]}, {enable, [?OFFLINE_DEF, ?ONLINE_DEF]}, {disable, [?OFFLINE_DEF, ?ONLINE_DEF]}, + {set, [?OFFLINE_DEF, ?ONLINE_DEF]}, {sync, []}]). %%---------------------------------------------------------------------------- @@ -157,6 +158,27 @@ action(enable, Node, ToEnable0, Opts, PluginsFile, PluginsDir) -> action_change( Opts, Node, ImplicitlyEnabled, NewImplicitlyEnabled, PluginsFile); +action(set, Node, ToSet0, Opts, PluginsFile, PluginsDir) -> + ToSet = [list_to_atom(Name) || Name <- ToSet0], + AllPlugins = rabbit_plugins:list(PluginsDir), + Enabled = rabbit_plugins:read_enabled(PluginsFile), + ImplicitlyEnabled = rabbit_plugins:dependencies(false, Enabled, AllPlugins), + Missing = ToSet -- plugin_names(AllPlugins), + case Missing of + [] -> ok; + _ -> throw({error_string, fmt_missing(Missing)}) + end, + NewImplicitlyEnabled = rabbit_plugins:dependencies(false, + ToSet, AllPlugins), + write_enabled_plugins(PluginsFile, ToSet), + case NewImplicitlyEnabled of + [] -> io:format("All plugins are now disabled.~n"); + _ -> print_list("The following plugins are now enabled:", + NewImplicitlyEnabled) + end, + action_change( + Opts, Node, ImplicitlyEnabled, NewImplicitlyEnabled, PluginsFile); + action(disable, Node, ToDisable0, Opts, PluginsFile, PluginsDir) -> case ToDisable0 of [] -> throw({error_string, "Not enough arguments for 'disable'"}); |