Convert egs_zones_sup to a simple_one_for_one supervisor.
This commit is contained in:
parent
c42b1a85f8
commit
408e7e99e6
@ -43,7 +43,7 @@ zone_pid(Pid, ZoneID) ->
|
||||
init([UniID, QuestID]) ->
|
||||
Zones = egs_quests_db:quest_zones(QuestID),
|
||||
ZonesPids = lists:map(fun({ZoneID, ZoneData}) ->
|
||||
{ok, Pid} = supervisor:start_child(egs_zones_sup, {{zone, UniID, QuestID, ZoneID}, {egs_zones, start_link, [UniID, QuestID, ZoneID, ZoneData]}, permanent, 5000, worker, dynamic}),
|
||||
{ok, Pid} = egs_zones_sup:start_zone(UniID, QuestID, ZoneID, ZoneData),
|
||||
{ZoneID, Pid}
|
||||
end, Zones),
|
||||
{ok, #state{zones=ZonesPids}}.
|
||||
|
@ -20,19 +20,26 @@
|
||||
-module(egs_zones_sup).
|
||||
-behaviour(supervisor).
|
||||
|
||||
-export([start_link/0]). %% API.
|
||||
-export([start_link/0, start_zone/4]). %% API.
|
||||
-export([init/1]). %% supervisor.
|
||||
|
||||
-define(SUPERVISOR, ?MODULE).
|
||||
|
||||
%% API.
|
||||
|
||||
-spec start_link() -> {ok, Pid::pid()}.
|
||||
-spec start_link() -> {ok, pid()}.
|
||||
start_link() ->
|
||||
supervisor:start_link({local, ?SUPERVISOR}, ?MODULE, []).
|
||||
|
||||
-spec start_zone(egs:uniid(), egs:questid(), egs:zoneid(), tuple())
|
||||
-> {ok, pid()}.
|
||||
start_zone(UniID, QuestID, ZoneID, ZoneData) ->
|
||||
supervisor:start_child(?SUPERVISOR, [UniID, QuestID, ZoneID, ZoneData]).
|
||||
|
||||
%% supervisor.
|
||||
|
||||
-spec init([]) -> {ok, {{simple_one_for_one, 0, 1}, [{_, _, _, _, _, _}, ...]}}.
|
||||
init([]) ->
|
||||
Procs = [],
|
||||
{ok, {{one_for_one, 10, 10}, Procs}}.
|
||||
{ok, {{simple_one_for_one, 0, 1}, [{egs_zones,
|
||||
{egs_zones, start_link, []}, temporary, brutal_kill,
|
||||
worker, [egs_zones]}]}}.
|
||||
|
Loading…
Reference in New Issue
Block a user