0
start_link() ->
supervisor:start_link(m_supervisor, []).
init(_Args) ->
{ok, {{one_for_one, 1, 60},
[{m_clock, {m_clock, start_link, []},
permanent, brutal_kill, worker, [m_clock]},
{m_sensor_f, {m_sensor_f, start_link, []},
permanent, brutal_kill, worker, [m_sensor_f]},
{m_sensor_c, {m_sensor_c, start_link, []},
permanent, brutal_kill, worker, [m_sensor_c]},
{m_converter, {m_converter, start_link, []},
permanent, brutal_kill, worker, [m_converter]},
{m_supervisor, {m_supervisor, start_link, []},
permanent, brutal_kill, worker, [m_supervisor]},
{m_display, {m_display, start_link, []},
permanent, brutal_kill, worker, [m_display]}
]}}.
如何在一位主管中監督多個模塊?Erlang如何監督多個模塊
當我開始運行這個上司,它告訴我:
** exception exit: {shutdown,
{failed_to_start_child,m_sensor_f,
{badarg,
[{erlang,register,[sensor,<0.51.0>],[]},
{m_sensor_f,start_sensor_f,2,
[{file,"m_sensor_f.erl"},{line,46}]},
{m_sensor_f,init,1,
[{file,"m_sensor_f.erl"},{line,16}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,306}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,237}]}]}}}
我怎樣才能解決這個問題?
它看起來像模塊的不止一個嘗試註冊的名字'sensor',即他們所謂像'gen_server:START_LINK({本地,傳感器},模塊{},[])' 。可以使用唯一名稱,也可以啓動沒有名稱的進程,例如'gen_server:start_link(?MODULE,{},[])'。 – legoscia 2015-03-13 15:29:12