Skip to content

Commit 1409ce2

Browse files
Merge branch 'rabbitmqctl-shutdown-custom-exit-code-to-indicate-server-reported-failure' into stable
2 parents be796e0 + 51aca88 commit 1409ce2

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

include/rabbit_cli.hrl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@
7272
-define(EX_SOFTWARE , 70). % Failed to execute command.
7373
-define(EX_TEMPFAIL , 75). % Temporary error (e.g. something has timed out).
7474
-define(EX_CONFIG , 78). % Misconfiguration detected
75+
76+
% Non-standard code that indicates that node shutdown failed with an error
77+
% other than an unsuccessfull RPC call or a timeout. See rabbitmq/rabbitmq-server#1396
78+
% for context.
79+
-define(EX_SHUTDOWN_ERROR, 79).

src/rabbit.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ stop_and_halt() ->
453453
stop()
454454
catch Type:Reason ->
455455
rabbit_log:error("Error trying to stop RabbitMQ: ~p:~p", [Type, Reason]),
456-
error({Type, Reason})
456+
erlang:error({Type, Reason})
457457
after
458458
%% Enclose all the logging in the try block.
459459
%% init:stop() will be called regardless of any errors.

src/rabbit_cli.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ main(ParseFun, DoFun, UsageMod) ->
9393
{'EXIT', {function_clause, [{?MODULE, action, _, _} | _]}} -> %% >= R15
9494
PrintInvalidCommandError(),
9595
usage(UsageMod);
96+
{error, {error_during_shutdown, Err}} ->
97+
print_error("Node ~w failed to shut down: ~p.",
98+
[Node, Err]),
99+
rabbit_misc:quit(?EX_SHUTDOWN_ERROR);
96100
{error, {missing_dependencies, Missing, Blame}} ->
97101
print_error("dependent plugins ~p not found; used by ~p.",
98102
[Missing, Blame]),

src/rabbit_control_main.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,13 @@ shutdown_node_and_wait_pid_to_stop(Node, Pid, Inform) ->
283283
wait_for_process_death(Pid),
284284
Inform(
285285
"RabbitMQ node ~p running at PID ~s successfully shut down",
286-
[Node, Pid]);
287-
_ -> ok
288-
end,
289-
Res.
286+
[Node, Pid]),
287+
Res;
288+
{error, Err} ->
289+
{error, {error_during_shutdown, Err}};
290+
_ ->
291+
Res
292+
end.
290293

291294
action(shutdown, Node, [], _Opts, Inform) ->
292295
case rpc:call(Node, os, getpid, []) of

0 commit comments

Comments
 (0)