summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit.erl61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 542c4b11c3..092ca37cf6 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -23,7 +23,7 @@
-behaviour(application).
-export([start/0, boot/0, stop/0,
- stop_and_halt/0, await_startup/0, await_startup/1, await_startup/2,
+ stop_and_halt/0, await_startup/0, await_startup/1, await_startup/3,
status/0, is_running/0, alarms/0,
is_running/1, environment/0, rotate_logs/0,
start_fhc/0]).
@@ -699,35 +699,36 @@ is_booting(Node) ->
-spec await_startup() -> 'ok' | {'error', 'timeout'}.
-
await_startup() ->
- await_startup(node()).
+ await_startup(node(), false).
-spec await_startup(node() | non_neg_integer()) -> 'ok' | {'error', 'timeout'}.
-
-await_startup(Timeout) when is_integer(Timeout) ->
- await_startup(node(), Timeout);
await_startup(Node) when is_atom(Node) ->
+ await_startup(Node, false);
+ await_startup(Timeout) when is_integer(Timeout) ->
+ await_startup(node(), false, Timeout).
+
+-spec await_startup(node(), boolean()) -> 'ok' | {'error', 'timeout'}.
+await_startup(Node, PrintProgressReports) ->
case is_booting(Node) of
- true -> wait_for_boot_to_finish(Node);
+ true -> wait_for_boot_to_finish(Node, PrintProgressReports);
false ->
case is_running(Node) of
- true -> ok;
+ true -> ok;
false -> wait_for_boot_to_start(Node),
- wait_for_boot_to_finish(Node)
+ wait_for_boot_to_finish(Node, PrintProgressReports)
end
end.
--spec await_startup(node(), non_neg_integer()) -> 'ok' | {'error', 'timeout'}.
-
-await_startup(Node, Timeout) ->
+-spec await_startup(node(), boolean(), non_neg_integer()) -> 'ok' | {'error', 'timeout'}.
+await_startup(Node, PrintProgressReports, Timeout) ->
case is_booting(Node) of
- true -> wait_for_boot_to_finish(Node, Timeout);
+ true -> wait_for_boot_to_finish(Node, PrintProgressReports, Timeout);
false ->
case is_running(Node) of
true -> ok;
false -> wait_for_boot_to_start(Node, Timeout),
- wait_for_boot_to_finish(Node, Timeout)
+ wait_for_boot_to_finish(Node, PrintProgressReports, Timeout)
end
end.
@@ -752,15 +753,18 @@ do_wait_for_boot_to_start(Node, IterationsLeft) ->
end.
wait_for_boot_to_finish(Node) ->
- wait_for_boot_to_finish(Node, ?BOOT_FINISH_TIMEOUT).
+ wait_for_boot_to_finish(Node, false, ?BOOT_FINISH_TIMEOUT).
+
+wait_for_boot_to_finish(Node, PrintProgressReports) ->
+ wait_for_boot_to_finish(Node, PrintProgressReports, ?BOOT_FINISH_TIMEOUT).
-wait_for_boot_to_finish(Node, Timeout) ->
+wait_for_boot_to_finish(Node, PrintProgressReports, Timeout) ->
Iterations = Timeout div ?BOOT_STATUS_CHECK_INTERVAL,
- do_wait_for_boot_to_finish(Node, Iterations).
+ do_wait_for_boot_to_finish(Node, PrintProgressReports, Iterations).
-do_wait_for_boot_to_finish(_Node, IterationsLeft) when IterationsLeft =< 0 ->
+do_wait_for_boot_to_finish(_Node, _PrintProgressReports, IterationsLeft) when IterationsLeft =< 0 ->
{error, timeout};
-do_wait_for_boot_to_finish(Node, IterationsLeft) ->
+do_wait_for_boot_to_finish(Node, PrintProgressReports, IterationsLeft) ->
case is_booting(Node) of
false ->
%% We don't want badrpc error to be interpreted as false,
@@ -773,16 +777,21 @@ do_wait_for_boot_to_finish(Node, IterationsLeft) ->
{badrpc, _} = Err ->
Err;
true ->
- case IterationsLeft rem 100 of
- %% This will be printed on the CLI command end to illustrate some
- %% progress.
- 0 -> io:format("Still booting, will check again in 10 seconds...~n");
- _ -> ok
- end,
+ maybe_print_boot_progress(PrintProgressReports, IterationsLeft),
timer:sleep(?BOOT_STATUS_CHECK_INTERVAL),
- do_wait_for_boot_to_finish(Node, IterationsLeft - 1)
+ do_wait_for_boot_to_finish(Node, PrintProgressReports, IterationsLeft - 1)
end.
+maybe_print_boot_progress(false = _PrintProgressReports, _IterationsLeft) ->
+ ok;
+maybe_print_boot_progress(true, IterationsLeft) ->
+ case IterationsLeft rem 100 of
+ %% This will be printed on the CLI command end to illustrate some
+ %% progress.
+ 0 -> io:format("Still booting, will check again in 10 seconds...~n");
+ _ -> ok
+ end.
+
status() ->
S1 = [{pid, list_to_integer(os:getpid())},
%% The timeout value used is twice that of gen_server:call/2.