Post upgrade command

[#166480167]
This commit is contained in:
dcorbacho 2019-09-18 11:37:18 +01:00
parent 611755e53e
commit dc29e5546c
5 changed files with 57 additions and 4 deletions

View File

@ -41,7 +41,8 @@ ERLANG_MK_COMMIT = rabbitmq-tmp
ACTUAL_ESCRIPTS = escript/rabbitmqctl
LINKED_ESCRIPTS = escript/rabbitmq-plugins \
escript/rabbitmq-diagnostics \
escript/rabbitmq-queues
escript/rabbitmq-queues \
escript/rabbitmq-upgrade
ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)
# Record the build and link dependency: the target files are linked to
@ -49,7 +50,8 @@ ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)
rabbitmq-plugins = escript/rabbitmqctl
rabbitmq-diagnostics = escript/rabbitmqctl
rabbitmq-queues = escript/rabbitmqctl
escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues: escript/rabbitmqctl
rabbitmq-upgrade = escript/rabbitmqctl
escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-upgrade: escript/rabbitmqctl
# We use hardlinks or symlinks in the `escript` directory and
# install's PREFIX when a single escript can have several names (eg.

View File

@ -40,7 +40,7 @@ Dependencies are being resolved by `erlang.mk`
### Building Standalone Executables
This repo produces a `rabbitmqctl` executable which can be used as different tools
(`rabbitmq-plugins`, `rabbitmq-diagnostics`, `rabbitmq-queues`) by copying or symlinking it with different names.
(`rabbitmq-plugins`, `rabbitmq-diagnostics`, `rabbitmq-queues`, `rabbitmq-upgrade`) by copying or symlinking it with different names.
Depending on the name, a different set of commands will be loaded and available, including
for `--help`.

View File

@ -68,4 +68,5 @@ defmodule RabbitMQ.CLI.Core.DocGuide do
Macros.defguide("tls", path_segment: "ssl")
Macros.defguide("troubleshooting")
Macros.defguide("virtual_hosts", path_segments: "vhosts")
Macros.defguide("upgrade")
end

View File

@ -0,0 +1,49 @@
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
## at https://www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS IS"
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
## the License for the specific language governing rights and
## limitations under the License.
##
## The Original Code is RabbitMQ.
##
## The Initial Developer of the Original Code is GoPivotal, Inc.
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Upgrade.Commands.PostUpgradeCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
use RabbitMQ.CLI.Core.MergesNoDefaults
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
def run([], %{node: node_name}) do
arg = String.to_atom("all")
:rabbit_misc.rpc_call(node_name, :rabbit_amqqueue, :rebalance, [arg, ".*", ".*"])
end
def formatter(), do: RabbitMQ.CLI.Formatters.PrettyTable
def usage, do: "post_upgrade"
def usage_doc_guides() do
[
DocGuide.upgrade()
]
end
def help_section, do: :upgrade
def description, do: "Post upgrade tasks"
def banner([], _) do
"Executing post upgrade tasks...\nRebalancing all queues..."
end
end

View File

@ -39,7 +39,8 @@ defmodule RabbitMQCtl.MixfileBase do
env: [scopes: ['rabbitmq-plugins': :plugins,
rabbitmqctl: :ctl,
'rabbitmq-diagnostics': :diagnostics,
'rabbitmq-queues': :queues]]
'rabbitmq-queues': :queues,
'rabbitmq-upgrade': :upgrade]]
]
|> add_modules(Mix.env)
end