rabbitmq-server/deps/rabbitmq_cli
Jean-Sébastien Pédron b15eb0ff1b
rabbit_db: `join/2` now takes care of stopping/starting RabbitMQ
[Why]
Up until now, a user had to run the following three commands to expand a
cluster:
1. stop_app
2. join_cluster
3. start_app

Stopping and starting the `rabbit` application and taking care of the
underlying Mnesia application could be handled by `join_cluster`
directly.

[How]
After the call to `can_join/1` and before proceeding with the actual
join, the code remembers the state of `rabbit`, the Feature flags
controler and Mnesia.

After the join, it restarts whatever needs to be restarted to. It does
so regardless of the success or failure of the join. One exception is
when the node switched from Mnesia to Khepri as part of that join. In
this case, Mnesia is left stopped.
2023-10-26 11:22:47 +02:00
..
config Update elixir logger config for 1.15+ 2023-07-04 17:45:50 +02:00
include
lib rabbit_db: `join/2` now takes care of stopping/starting RabbitMQ 2023-10-26 11:22:47 +02:00
test rabbit_khepri: Remove Mnesia files after migration 2023-10-17 09:38:12 +02:00
.formatter.exs initial .formatter.exs configuration file 2022-10-02 18:52:43 +01:00
.gitignore
BUILD.bazel Run cli format check on elixir 1.15 only 2023-07-04 17:45:50 +02:00
CODE_OF_CONDUCT.md
COMMAND_TUTORIAL.md remove repetitive words (#8981) 2023-07-31 12:50:52 +02:00
CONTRIBUTING.md
DESIGN.md Add inclusive aliases to ctl info keys 2022-11-11 14:44:05 -08:00
LICENSE Replace @rabbitmq.com addresses with rabbitmq-core@groups.vmware.com 2023-06-20 15:40:13 +04:00
LICENSE-MPL-RabbitMQ
Makefile Bump CSV to 3.0.5 in erlang.mk (#8448) 2023-06-01 15:11:28 +02:00
README.md Update CLI build requirements to match our pipelines 2022-06-05 16:36:53 +04:00
mix.exs rabbitmq_cli: Handle absence of the `rabbit_db*` modules in older versions 2023-09-04 21:09:11 +02:00
rabbitmqctl.bzl Fix rabbitmq_cli test compilation under elixir 1.15 2023-07-04 17:45:32 +02:00
rabbitmqctl_check_formatted.bzl Fixup format check on windows 2022-11-02 11:50:42 +01:00
rabbitmqctl_test.bzl Fix rabbitmq_cli test compilation under elixir 1.15 2023-07-04 17:45:32 +02:00

README.md

RabbitMQ CLI Tools

Build Status

This repository contains RabbitMQ CLI tools (rabbitmqctl and others).

This generation of CLI tools first shipped with RabbitMQ 3.7.0.

Goals

Team RabbitMQ wanted a set of tools that

  • Was extensible from/with plugins
  • Supported pluggable output formats (in particular machine-friendly ones)
  • Had good test coverage
  • Wasn't as coupled to the server repository
  • Could be used as a low risk vehicle for Elixir evaluation

Supported RabbitMQ Versions

Long lived branches in this repository track the same branch in RabbitMQ core and related repositories. So master tracks master in rabbitmq-server, v3.10.x tracks branch v3.10.x in rabbitmq-server and so on.

Please use the version of CLI tools that come with the RabbitMQ distribution version installed.

Building

Requirements

Building this project requires

  • Erlang/OTP 23.3 (or later)
  • Elixir 1.12.0 (or later).

Command line tools depend on rabbitmq-common. 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, rabbitmq-streams, 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.

To generate the executable, run

make

Usage

rabbitmqctl

See rabbitmqctl help and rabbitmqctl man page for details.

rabbitmq-plugins

See rabbitmq-plugins help and rabbitmq-plugins man page for details.

rabbitmq-diagnostics

See rabbitmq-diagnostics help and rabbitmq-diagnostics man page.

Testing

See CONTRIBUTING.md.

Developing

Adding a New Command

Conventions

RabbitMQ CLI tools use module name conventions to match the command-line actions (commands) to modules. The convention is outlined in the CommandBehaviour module.

Command Module Interface

Each command module must implement the RabbitMQ.CLI.CommandBehaviour behaviour, which includes the following functions:

  • validate(args, opts), which returns either :ok or a tuple of {:validation_failure, failure_detail} where failure detail is typically one of: :too_many_args, :not_enough_args or {:bad_argument, String.t}.

  • merge_defaults(args, opts), which is used to return updated arguments and/or options.

  • run(args, opts), where the actual command is implemented. Here, args is a list of command-specific parameters and opts is a Map containing option flags.

  • usage, which returns a string describing the command, its arguments and its optional flags.

  • banner(args, opts), which returns a string to be printed before the command output.

There are also a number of optional callbacks:

  • switches, which returns command specific switches.
  • aliases, which returns a list of command aliases (if any).
  • formatter: what output formatter should be used by default.
  • usage_additional: extra values appended to the usage output to provide additional command-specific documentation.
  • scopes: what scopes this command appears in. Scopes associate tools (e.g. rabbitmqctl, rabbitmq-diagnostics, rabbitmq-queues, rabbitmq-streams) with commands.
  • distribution: control erlang distribution. Can be :cli (default), :none or {:fun, fun}

Tutorial

We have a tutorial that demonstrates how to add a CLI command that deletes a queue.

Examples

See lib/rabbitmq/cli/ctl/commands/status_command.ex and test/status_command_test.exs for minimalistic but not entirely trivial examples.

The project is licensed under the MPL, the same license as RabbitMQ.

(c) 2007-2020 VMware, Inc. or its affiliates.