【发布时间】:2011-06-29 20:17:59
【问题描述】:
我尝试将应用程序写入我的 Erlang 程序。
我有 test_app.erl:
-module(test_app).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
start(_Type, _StartArgs) ->
test_sup:start_link().
stop(_State) ->
ok.
还有.app文件:
{application, test,
[{description, "test system."},
{vsn, "1.0"},
{modules, [test_app, test_sup, fsm]},
{registered, [test_sup, fsm]},
{applications, [kernel, stdlib]},
{mod, {test_app, []}}
]}.
当我尝试启动应用程序时:
application:start(test).
我得到错误:
=INFO REPORT==== 18-Feb-2011::19:38:53 ===
application: test
exited: {bad_return,
{{test_app,start,[normal,[]]},
{'EXIT',
{undef,
[{test_sup,start_link,[[]]},
{test_app,start,2},
{application_master,start_it_old,4}]}}}}
type: temporary
{error,{bad_return,{{test_app,start,[normal,[]]},
{'EXIT',{undef,[{test_sup,start_link,[[]]},
{test_app,start,2},
{application_master,start_it_old,4}]}}}}}
怎么了?我该如何解决?
如果我在 eshell 中制作:
test_app:start(normal, []).
比一切都好。
谢谢。
【问题讨论】:
-
它告诉您函数
test_sup:start_link([])不存在 ({test_sup,start_link,[[]]}),但您在给我们的代码中使用test_sup:start_link()调用它。此外,您的 .app 文件显示模块epmail_app是应该调用的模块,而您的应用程序显然以test_app开头。有没有你没有正确发布的东西,或者我只是在想象一些事情?如果是这样的话,关于返回值,Yasir 的回答是对的。 -
另外,查看主管
test_sup的代码会很方便。 -
我认为主管代码很好,因为如果我尝试手动运行主管一切正常。
-
您是否重新编译了所有模块?
标签: erlang erlang-otp