2

我尝试将应用程序写入我的 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, []).

比所有的作品。

谢谢你。

4

1 回答 1

3

我想这可能是由于未加载 [proper] .beam 造成的。确保所有模块都在同一目录中,或尝试使用-pakey to erl(1),例如:

$ erl -pa ../ebin
1> application:start(test).
...
于 2011-02-18T17:32:35.327 回答