Я определяю рабочую спецификацию simple_one_for_one для одного руководителя с именем band_supervisor, а идентификатор дочерней спецификации — jam_musician
:
init([]) ->
{ok, {{simple_one_for_one, 3, 60},
[{jam_musician,
{musicians, start_link, []},
temporary, 1000, worker, [musicians]}
]}};
модуль музыкантов это:
-module(musicians).
-behaviour(gen_server).
-export([start_link/2, stop/1]).
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, code_change/3, terminate/2]).
-record(state, {name="", role, skill=good}).
-define(DELAY, 750).
start_link(Role, Skill) ->
gen_server:start_link({local, Role}, ?MODULE, [Role, Skill], []).
stop(Role) -> gen_server:call(Role, stop).
и я могу создать много рабочих:
3> supervisor:start_child(band_supervisor, [drum, good]).
Musician Arnold Ramon, playing the drum entered the room
{ok,<0.696.0>}
3> supervisor:start_child(band_supervisor, [guitar, good]).
Musician Wanda Perlstein, playing the guitar entered the room
{ok,<0.698.0>}
Я заметил, что все рабочие имеют один и тот же идентификатор дочерней спецификации: jam_musician
Вы знаете, что другие рабочие типы должны иметь уникальный дочерний идентификатор, верно?
musicians
, пожалуйста? Похоже, вы регистрируете дочерние процессы с тем же именем. - person Isac   schedule 02.04.2013already_started
от руководителяsimple_one_for_one
. - person rvirding   schedule 02.04.2013