diff options
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 4e24d1b544..c52949af4c 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -485,16 +485,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. |
