【问题标题】:Erlang "Kernel pid terminated" errorErlang“内核pid终止”错误
【发布时间】:2015-08-22 08:43:41
【问题描述】:

我尝试将 relx 用于发布应用程序。 Relx 毫无问题地做到了。但是当我启动应用程序时,我有错误:

{"Kernel pid terminated",application_controller,"
{application_start_failure,iqServer,{bad_return,{{iqServer_app,start,[normal,[]]},  
{'EXIT',{undef,[{iqServer_app,start,[normal,[]],[]},
{application_master,start_it_old,4,[{file,\"application_master.erl\"},
{line,272}]}]}}}}}"}

据我了解,我在函数iqServer:start/2 中存在问题。 start/2 看起来像这样:

-module(iqServer).
-behaviour(application).

-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
    Dispatch = dispatch_rules(),
    {ok, _} = cowboy:start_http(http_listener, 100, [
        {ip,{127,0,0,1}}, 
        {port, 6000}], [
        {env, [{dispatch, Dispatch}]}
    ]),
    iqServer_sup:start_link().

stop(_State) ->
    ok.

dispatch_rules() ->
    cowboy_router:compile([
        {'_', [
            {"/test/", cowboy_static, {file, "priv/index.html"}},
            {"/test/:group/:method", iqServer_test_handler, []}
        ]}
    ]).

之前我通过这个命令启动了我的应用程序:erl -pa ebin deps/*/ebin -s iqServer,它运行良好。现在我不知道麻烦在哪里。

这是我的 iqServer.app.src 文件:

{application, iqServer,
 [
  {description, "Test app"},
  {vsn, "0.1"},
  {registered, [iqServer]},
  {applications, [
                  kernel,
                  stdlib,
                  crypto,
                  cowlib,
                  ranch,
                  gproc,
                  cowboy
                 ]},
  {mod, { iqServer_app, []}},
  {modules, [
      iqServer,
      .....
      iqServer_sup,
      iqServer_tools
      ]}
 ]}.

生成文件:

PROJECT = iqServer

DEPS = cowboy sync gproc jsx epgsql
COMPILE_FIRST = iqServer_api_method
ERLC_OPTS = +debug_info
dep_cowboy = git https://github.com/ninenines/cowboy.git HEAD
dep_gproc = git git://github.com/esl/gproc.git HEAD
dep_jsx = git git://github.com/talentdeficit/jsx.git HEAD
dep_epgsql = git git://github.com/epgsql/epgsql.git HEAD

include erlang.mk

relx.config:

{release, {iqServer, "1"}, [iqServer]}.

{extended_start_script, true}.
{sys_config, "rel/sys.config"}.

{vm_args, "rel/vm.args"}.

【问题讨论】:

  • 定义start函数的模块名称是什么?
  • @legoscia 名称是 iqServer。我在主题中添加了这个模块的完整代码。
  • 可能是版本问题

标签: erlang rebar relx reltool


【解决方案1】:

在您的应用文件中,您有以下行:

  {mod, { iqServer_app, []}},

这意味着在启动应用程序时,应该调用iqServer_app 模块中的start/2 函数。但是,您的应用程序回调模块称为iqServer。要么更改应用文件中的模块名称,要么重命名模块。

【讨论】:

猜你喜欢
  • 2013-09-09
  • 2018-03-11
  • 2016-08-09
  • 2017-07-06
  • 2013-03-06
  • 1970-01-01
  • 2012-11-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多