我尝试将 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"}.