1## This Source Code Form is subject to the terms of the Mozilla Public 2## License, v. 2.0. If a copy of the MPL was not distributed with this 3## file, You can obtain one at https://mozilla.org/MPL/2.0/. 4## 5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. 6 7defmodule RabbitMQ.CLI.Diagnostics.Commands.IsBootingCommand do 8 @behaviour RabbitMQ.CLI.CommandBehaviour 9 10 use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout 11 use RabbitMQ.CLI.Core.MergesNoDefaults 12 use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments 13 14 def run([], %{node: node_name, timeout: timeout}) do 15 :rabbit_misc.rpc_call(node_name, :rabbit, :is_booting, [node_name], timeout) 16 end 17 18 def output(true, %{node: node_name, formatter: "json"}) do 19 m = %{ 20 "result" => true, 21 "message" => "RabbitMQ on node #{node_name} is booting" 22 } 23 {:ok, m} 24 end 25 26 def output(false, %{node: node_name, formatter: "json"}) do 27 m = %{ 28 "result" => false, 29 "message" => "RabbitMQ on node #{node_name} is fully booted (check with is_running), stopped or has not started booting yet" 30 } 31 {:ok, m} 32 end 33 def output(true, %{node: node_name}) do 34 {:ok, "RabbitMQ on node #{node_name} is booting"} 35 end 36 37 def output(false, %{node: node_name}) do 38 {:ok, 39 "RabbitMQ on node #{node_name} is fully booted (check with is_running), stopped or has not started booting yet"} 40 end 41 42 use RabbitMQ.CLI.DefaultOutput 43 44 def help_section(), do: :observability_and_health_checks 45 46 def description(), do: "Checks if RabbitMQ is still booting on the target node" 47 48 def usage, do: "is_booting" 49 50 def banner([], %{node: node_name}) do 51 "Asking node #{node_name} for its boot status ..." 52 end 53end 54