diff options
| author | Daniil Fedotov <dfedotov@pivotal.io> | 2017-04-10 17:09:25 +0100 |
|---|---|---|
| committer | Daniil Fedotov <dfedotov@pivotal.io> | 2017-04-10 17:09:25 +0100 |
| commit | f0da42683f491b527cd3358c91c9370d8be3d5fd (patch) | |
| tree | d41bbe8f271610d16661beb98ed118874aace1f5 /src/rabbit.erl | |
| parent | 0b0308829c716d3226c4d71efefe4d0b5f57473c (diff) | |
| download | rabbitmq-server-git-f0da42683f491b527cd3358c91c9370d8be3d5fd.tar.gz | |
Call init:stop() during rabbitmqctl stop even if logging fails.rabbitmq_v3_6_10_milestone1
This makes sure that we try to stop an erlang app even if an exception
is thrown during logging in the "after" block.
Otherwise there is an inconsistency between "failed and the erlang node will stop"
and "failed, but the erlang node will not stop"
Diffstat (limited to 'src/rabbit.erl')
| -rw-r--r-- | src/rabbit.erl | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 27d55b9d25..ba84f97610 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -450,16 +450,21 @@ stop_and_halt() -> rabbit_log:error("Error trying to stop RabbitMQ: ~p:~p", [Type, Reason]), error({Type, Reason}) after - AppsLeft = [ A || {A, _, _} <- application:which_applications() ], - rabbit_log:info( - lists:flatten(["Halting Erlang VM with the following applications:~n", - [" ~p~n" || _ <- AppsLeft]]), - AppsLeft), - %% Also duplicate this information to stderr, so console where - %% foreground broker was running (or systemd journal) will - %% contain information about graceful termination. - io:format(standard_error, "Gracefully halting Erlang VM~n", []), - init:stop() + %% Enclose all the logging in the try block. + %% init:stop() will be called regardless of any errors. + try + AppsLeft = [ A || {A, _, _} <- application:which_applications() ], + rabbit_log:info( + lists:flatten(["Halting Erlang VM with the following applications:~n", + [" ~p~n" || _ <- AppsLeft]]), + AppsLeft), + %% Also duplicate this information to stderr, so console where + %% foreground broker was running (or systemd journal) will + %% contain information about graceful termination. + io:format(standard_error, "Gracefully halting Erlang VM~n", []) + after + init:stop() + end end, ok. |
