linux - 如何将 child 添加到 erlang supervisor?

标签 linux erlang erlang-otp

我正在尝试将事件管理器添加到主管,但出现如下错误:

1> test_event_call:start_link().
{ok,<0.85.0>}
2> test_event_call:start_event().
{error,{ok,{child,undefined,test_event_proc,
                  {test_event,start,[]},
                  transient,200000,worker,
                  [test_event]}}}

主管模块是test_event_call.erl:

-module(test_event_call).
-behaviour(supervisor).
-export([start_link/0, start_event/0, init/1]).

start_link() ->
    supervisor:start_link({local, ?MODULE}, 
                          ?MODULE, []).

start_event() ->
    supervisor:start_child(?MODULE, {test_event_proc,
                                     {test_event, start, []},
                                     transient, 200000, worker, [test_event]}).

init(_Args) ->
    {ok, {{one_for_one, 1, 5}, []}}.

child 是test_event.erl:

-module(test_event).
-behaviour(gen_event).
-export([init/1, handle_event/2, handle_call/2, handle_info/2, terminate/2, code_change/3]).


-export([start/0, log_fun/2]).

start() ->
    {ok, _Pid} = gen_event:start_link({local, ?MODULE}),
    gen_event:add_handler(?MODULE, ?MODULE, []).

谁能帮我解决这个错误?

最佳答案

返回 {ok, Pid} 解决了我的问题。

关于linux - 如何将 child 添加到 erlang supervisor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43572000/

相关文章:

python - 如何配置 Jenkins "New Item"以将文件推送到网络上的特定服务器?

linux - xmessage 长文本 - 换行?

linux - 如何自动化多个服务器的 scp ?

linux - 在 Linux 中的单个列上进行 Grep

erlang - 如何向 CouchDB 添加插件

erlang - 尖括号之间的内容被 Erlang 的 common_test 框架默默地丢弃

Erlang计算HMAC-SHA1的例子?

c# - 与 C# 程序通信 Erlang 服务器

erlang - 当主 pipe 级从 start_link 返回错误时,如何始终记录/显示错误原因?

elixir - 子进程可以访问单个应用程序范围的进程