【问题标题】:Erlang application problemErlang应用问题
【发布时间】: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


【解决方案1】:

我想这可能是由于未加载 [正确] .beam 造成的。确保所有模块都在同一个目录下,或者尝试使用-pa 键对erl(1),例如。 g.:

$ erl -pa ../ebin
1> application:start(test).
...

【讨论】:

    猜你喜欢
    • 2013-01-06
    • 2011-09-29
    • 2018-09-22
    • 2011-05-27
    • 2010-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-12
    相关资源
    最近更新 更多