Skip to content

Commit

Permalink
Modify to terminate libs
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed May 7, 2014
1 parent 04f9172 commit 489d10a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
3 changes: 3 additions & 0 deletions src/leo_storage_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ start(_Type, _Args) ->
after_proc(Res).

prep_stop(_State) ->
catch leo_object_storage_sup:stop(),
catch leo_redundant_manager_sup:stop(),
catch leo_mq_sup:stop(),
catch leo_logger_sup:stop(),
catch leo_storage_sup:stop(),
ok.

Expand Down
24 changes: 1 addition & 23 deletions src/leo_storage_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@ start_link() ->
%% @doc stop process.
%% @end
stop() ->
case whereis(?MODULE) of
Pid when is_pid(Pid) ->
List = supervisor:which_children(Pid),
Len = length(List),

ok = terminate_children(List),
timer:sleep(Len * 100),
exit(Pid, shutdown),
ok;
_ ->
not_started
end.
ok.


%% ---------------------------------------------------------------------
Expand All @@ -79,14 +68,3 @@ init([]) ->
%% ---------------------------------------------------------------------
%% Internal Functions
%% ---------------------------------------------------------------------
%% @doc Terminate children
%% @private
-spec(terminate_children(list()) ->
ok).
terminate_children([]) ->
ok;
terminate_children([{_Id,_Pid, supervisor, [Mod|_]}|T]) ->
Mod:stop(),
terminate_children(T);
terminate_children([_|T]) ->
terminate_children(T).

0 comments on commit 489d10a

Please sign in to comment.