由于返回错误,无法启动Erlang应用程序

flvlnr44  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(149)

I have a simple erlang application and i am trying to start it to no avail getting a bad return error:

> {error,
>     {bad_return,
>         {{mapp,start,[normal,[]]},
>          {'EXIT',
>              {undef,
>                  [{mapp,start,[normal,[]],[]},
>                   {application_master,start_it_old,4,
>                       [{file,"application_master.erl"},{line,277}]}]}}}}}

.app

{
    application,mapp,
    [
        {vsn,"1.0.0"},
        {description,"some description"},
        {mod,{mapp,[]}},
        {modules,[mapp,m1]}
    ]   
}.

Folder structure:

-root
  -mapp.app
  -src
     -m1.erl
     -mapp.erl
  -include
      -state.hrl
  -ebin

Application

-module(mapp).
-behaviour(application).
-export([start/2,stop/1]).

start(normal,_Args)->
    Pid=m1:start_link(),
    {ok,Pid}.

stop(State)->ok.

Module

-module(m1).
-include("r.hrl").
-export([start_link/0]).

start_link()->
    Pid=spawn_link(?MODULE,serv,#state{count=2}),
    Pid.
serv(State=#state{count=C})->
    receive 
        {From,MSG} ->From ! {ok,MSG},
                     serv(State#state{count=C=1})
    end.

.hrl

-record(state,{
    count=0
    }).

So my m1 module returns a Pid .I comply to the application:start/2 return type and return a {ok,Pid} . What is wrong here ? I have tried both with Pid and {ok,Pid} to no avail.

slwdgvem

slwdgvem1#

错误说明mapp:start/2undef。看到您的mapp.erl导出它,我怀疑模块mapp没有加载。
你是如何运行应用程序的?我怀疑你没有使用像rebar3erlang.mk这样的发布工具,因为通常应用程序文件都在src中。

相关问题