Я написал простое приложение на Erlang, но оно отказывается работать со следующей ошибкой:
=SUPERVISOR REPORT==== 18-Jan-2012::15:03:27 ===
Supervisor: {<0.60.0>,my_sup}
Context: start_error
Reason: {'EXIT',{undef,[{my,start,[{8077,none}]},
{supervisor,do_start_child,2},
{supervisor,start_children,3},
{supervisor,init_children,2},
{gen_server,init_it,6},
{proc_lib,init_p_do_apply,3}]}}
Offender: [{pid,undefined},
{name,my},
{mfa,{my,start,[{8077,none}]}},
{restart_type,permanent},
{shutdown,brutal_kill},
{child_type,worker}]
=INFO REPORT==== 18-Jan-2012::15:03:27 ===
application: my
exited: {shutdown,{my_app,start,[normal,[noarg]]}}
type: temporary {error,{shutdown,{my_app,start,[normal,[noarg]]}}}
И модули:
my.erl
-module(my).
-export([start/2, stop/0]).
start(Port,_arg) ->
io:format("starting my").
stop() ->
ok.
my_app.erl Модуль приложения, выполните поведение application
.
-module(my_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_Type, _Args) ->
io:format("my server starting~n"),
my_sup:start_link().
stop(_State) ->
io:format("my server terminating~n"),
ok.
my_sup.erl Логика супервизора
-module(my_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link(my_sup, []).
init(_Args) ->
{ok, {
{one_for_one, 10, 60},
[{my, {my, start, [{8077,none}]
},
permanent, brutal_kill, worker, [my]}]}}.
Файл конфигурации (my.app):
{application, my,
[
{description, "Demo"},
{vsn, "1.0"},
{id, "hello"},
{modules, [my,my_sup]},
{registered, [my,my_sup]},
{applications, [kernel, stdlib]},
%%
%% mod: Specify the module name to start the application, plus args
%%
{mod, {my_app, [noarg]}},
{env, []}
]
}.
Я изменил дочернюю спецификацию, как вы рекомендуете, но проблема все еще остается.
=SUPERVISOR REPORT==== 19-Jan-2012::00:34:21 ===
Supervisor: {<0.96.0>,my_sup}
Context: start_error
Reason: <0.97.0>
Offender: [{pid,undefined},
{name,my},
{mfa,{my,start,[8077,none]}},
{restart_type,permanent},
{shutdown,brutal_kill},
{child_type,worker}]
=ERROR REPORT==== 19-Jan-2012::00:34:21 ===
Error in process <0.97.0> with exit value:
{{badmatch,{error,eaddrinuse}},[{my,'- start/2-fun-0-',1}]}
=INFO REPORT==== 19-Jan-2012::00:34:21 ===
application: my
exited: {shutdown,{my_app,start,[normal,[noarg]]}}
type: temporary
{error,{shutdown,{my_app,start,[normal,[noarg]]}}}