Erlang“Kernel pid terminated”错误 [英] Erlang "Kernel pid terminated" error
问题描述
我尝试使用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(应用程序)。
-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) - >
好的。
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文件:
<$
{vsn,0.1},
{注册,[iqServer]},
{applications,[
kernel,
stdlib,
crypto,
cowlib,
ranch,
gproc ,
牛仔
]},
{mod,{iqServer_app,[]}},
{modules,[
iqServer,
....
iqServer_sup,
iqServer_tools
]}
]}。
Makefile:
code> PROJECT = iqServer
DEPS =牛仔同步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}。
在你的应用程序文件中,你有这样一行: / p>
{mod,{iqServer_app,[]}},
$ p $这意味着启动应用程序时,
iqServer_app
模块应该被调用。但是,您的应用程序回调模块称为iqServer
。更改应用程序文件中的模块名称或重命名模块。I try to use relx for release application. Relx did it without problems. But when I start application, I have the error:
{"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}]}]}}}}}"}
As I understand from the error, I have a problem in the function
iqServer:start/2
.start/2
looks like that:-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, []} ]} ]).
Previously I started my application by this command:
erl -pa ebin deps/*/ebin -s iqServer
and it worked fine. And now I don't know where trouble is.This is my iqServer.app.src file:
{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 ]} ]}.
Makefile:
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"}.
解决方案In your app file, you have this line:
{mod, { iqServer_app, []}},
That means that when starting the application, the
start/2
function in theiqServer_app
module should be called. However, your application callback module is callediqServer
. Either change the module name in the app file, or rename the module.这篇关于Erlang“Kernel pid terminated”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!