无法使用erlang管理员启动服务器(gen服务器)

时间:2017-01-18 20:31:40

标签: erlang supervisor

我想使用提供的erlang主管启动服务器。但有一个例外。如果我尝试在没有主管的情况下启动服务器,那就是成功。

主管代码:

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

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

init([]) -> 
ServerChild1 = {server1,{my_server, start_link,[]},
                permanent, 2000, worker, [my_server]},
ServerChild2 = {server2,{my_server, start_link,[]},
                permanent, 2000, worker, [my_server]},
ServerChild3 = {server3,{my_server, start_link,[]},
                permanent, 2000, worker, [my_server]},
{ok,{{one_for_one,1,1000},[ServerChild1, ServerChild2, ServerChild3]}}.

我在my_server模式中违反了gen服务器回调函数。 服务器init([])功能代码:

-module(my_server).
-behaviour(gen_server).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,     code_change/3, helper/3]).

init([]) ->
process_flag(trap_exit,true),
{ok,0}.

但是,当我尝试通过输入以下命令启动我的服务器时:

  

server_sup:START_LINK()

我有退出例外。

任何人都知道为什么我不能通过我的主管启动它?

0 个答案:

没有答案
相关问题