diff options
| author | Diana Corbacho <diana@rabbitmq.com> | 2017-04-21 11:23:57 +0100 |
|---|---|---|
| committer | Diana Corbacho <diana@rabbitmq.com> | 2017-04-21 11:29:24 +0100 |
| commit | dcf15e7d894e536cc09bc065310d97fcee6c7d12 (patch) | |
| tree | 580e2e4afea644ea71b89fb2d6cd03c2634d9d07 /src | |
| parent | d8c66d10c495a9119a114f80a38b144a00f2b325 (diff) | |
| download | rabbitmq-server-git-dcf15e7d894e536cc09bc065310d97fcee6c7d12.tar.gz | |
Use new supervisor2:prep_stop to stop rabbit dependencies on shutdown
Only for when the top supervisor reaches its max restart intensity,
as stopping applications from application:stop/1 will block
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_sup.erl | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/rabbit_sup.erl b/src/rabbit_sup.erl index 38d561fa80..0622d16e61 100644 --- a/src/rabbit_sup.erl +++ b/src/rabbit_sup.erl @@ -16,7 +16,7 @@ -module(rabbit_sup). --behaviour(supervisor). +-behaviour(supervisor2). -export([start_link/0, start_child/1, start_child/2, start_child/3, start_child/4, start_supervisor_child/1, start_supervisor_child/2, @@ -25,7 +25,7 @@ start_delayed_restartable_child/1, start_delayed_restartable_child/2, stop_child/1]). --export([init/1]). +-export([init/1, prep_stop/0]). -include("rabbit.hrl"). @@ -49,20 +49,20 @@ %%---------------------------------------------------------------------------- -start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). +start_link() -> supervisor2:start_link({local, ?SERVER}, ?MODULE, []). start_child(Mod) -> start_child(Mod, []). start_child(Mod, Args) -> start_child(Mod, Mod, Args). start_child(ChildId, Mod, Args) -> - child_reply(supervisor:start_child( + child_reply(supervisor2:start_child( ?SERVER, {ChildId, {Mod, start_link, Args}, transient, ?WORKER_WAIT, worker, [Mod]})). start_child(ChildId, Mod, Fun, Args) -> - child_reply(supervisor:start_child( + child_reply(supervisor2:start_child( ?SERVER, {ChildId, {Mod, Fun, Args}, transient, ?WORKER_WAIT, worker, [Mod]})). @@ -73,7 +73,7 @@ start_supervisor_child(Mod) -> start_supervisor_child(Mod, []). start_supervisor_child(Mod, Args) -> start_supervisor_child(Mod, Mod, Args). start_supervisor_child(ChildId, Mod, Args) -> - child_reply(supervisor:start_child( + child_reply(supervisor2:start_child( ?SERVER, {ChildId, {Mod, start_link, Args}, transient, infinity, supervisor, [Mod]})). @@ -85,20 +85,25 @@ start_delayed_restartable_child(M, A) -> start_restartable_child(M, A, true). start_restartable_child(Mod, Args, Delay) -> Name = list_to_atom(atom_to_list(Mod) ++ "_sup"), - child_reply(supervisor:start_child( + child_reply(supervisor2:start_child( ?SERVER, {Name, {rabbit_restartable_sup, start_link, [Name, {Mod, start_link, Args}, Delay]}, transient, infinity, supervisor, [rabbit_restartable_sup]})). stop_child(ChildId) -> - case supervisor:terminate_child(?SERVER, ChildId) of - ok -> supervisor:delete_child(?SERVER, ChildId); + case supervisor2:terminate_child(?SERVER, ChildId) of + ok -> supervisor2:delete_child(?SERVER, ChildId); E -> E end. init([]) -> {ok, {{one_for_all, 0, 1}, []}}. +prep_stop() -> + rabbit_log:info("Stopping dependencies...~n",[]), + Apps = rabbit_plugins:active(), + rabbit:stop_apps(app_utils:app_dependency_order(Apps, true)), + rabbit_log:info("Dependencies stopped...~n",[]). %%---------------------------------------------------------------------------- |
