Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Make rabbit application transient #194

Merged
merged 3 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/app_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ stop_applications(Apps) ->

start_applications(Apps, ErrorHandler) ->
manage_applications(fun lists:foldl/3,
fun application:start/1,
fun start/1,
fun application:stop/1,
already_started,
ErrorHandler,
Expand All @@ -62,7 +62,7 @@ stop_applications(Apps, ErrorHandler) ->
rabbit_log:info("Stopping application '~s'", [App]),
application:stop(App)
end,
fun application:start/1,
fun start/1,
not_started,
ErrorHandler,
Apps).
Expand Down Expand Up @@ -124,3 +124,9 @@ manage_applications(Iterate, Do, Undo, SkipError, ErrorHandler, Apps) ->
end, [], Apps),
ok.

start(rabbit) ->
%% Stops the Erlang VM when the rabbit application stops abnormally
%% i.e. message store reaches its restart limit
application:start(rabbit, transient);
start(App) ->
application:start(App).
25 changes: 1 addition & 24 deletions src/supervisor2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@
[ChildSpec :: child_spec()]}}
| ignore.

%% Optional callback prep_stop/0. It cannot be exported as Erlang/OTP doesn't
%% support definition of optional callbacks.
%%
%% Currently used to stop application dependencies.
%%
%% -callback prep_stop() -> ok.
%%

-define(restarting(_Pid_), {restarting,_Pid_}).

%%% ---------------------------------------------------
Expand Down Expand Up @@ -637,7 +629,6 @@ handle_info({'EXIT', Pid, Reason}, State) ->
{ok, State1} ->
{noreply, State1};
{shutdown, State1} ->
prep_stop(State1),
{stop, shutdown, State1}
end;

Expand Down Expand Up @@ -810,8 +801,7 @@ restart_child(Pid, Reason, State) ->
try_restart(RestartType, Reason, Child, State) ->
case handle_restart(RestartType, Reason, Child, State) of
{ok, NState} -> {noreply, NState};
{shutdown, State2} -> prep_stop(State2),
{stop, shutdown, State2}
{shutdown, State2} -> {stop, shutdown, State2}
end.

do_restart(RestartType, Reason, Child, State) ->
Expand Down Expand Up @@ -1514,16 +1504,3 @@ report_progress(Child, SupName) ->
Progress = [{supervisor, SupName},
{started, extract_child(Child)}],
error_logger:info_report(progress, Progress).

prep_stop(#state{module = Mod}) ->
%% Catch any exception - including non-existing prep_stop -
%% and continue stopping the supervision tree.
%% This is only executed when children are terminating,
%% because any other call from a top supervisor or application
%% will cause a deadlock stopping applications within prep_stop.
try
Mod:prep_stop()
catch
_:_ ->
ok
end.