我正在尝试运行我的服务器。我将我的src文件复制到一个新的牛仔安装中,这是我得到的错误。
~/cowboy_ninja:.ls src
action_handler.erl gate.beam resolution.beam
arena.beam gate.erl resolution.erl
arena.erl guestbook.beam temple.beam
cowboy_ninja_app.erl guestbook.erl temple.erl
cowboy_ninja_sup.erl hello_handler.erl
~/cowboy_ninja:.
cat src / cowboy_ninja_app.erl
-module(cowboy_ninja_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/action", action_handler, []},
{"/join", hello_handler, []}]}
]),
{ok, _} = cowboy:start_clear(my_http_listener, 100,
[{port, 8080}],
#{env => #{dispatch => Dispatch}}
),
{ok, Pid} = gate:start_link(),
register(gate, Pid),
{ok, Guestbook} = guestbook:start_link(),
register(guestbook, Guestbook),
gate:action(Pid, {fight}),
cowboy_ninja_sup:start_link().
stop(_State) ->
ok.
见下文。
~/cowboy_ninja:.gmake run
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/cowboy_ninja/ebin
/Users/quantum/cowboy_ninja/deps
/usr/local/Cellar/erlang/19.1/lib/erlang/lib
/Users/quantum/cowboy_ninja/apps
/Users/quantum/cowboy_ninja/_rel
===> Resolved cowboy_ninja_release-1
===> Including Erts from /usr/local/Cellar/erlang/19.1/lib/erlang
===> release successfully created!
===> tarball /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/cowboy_ninja_release-1.tar.gz successfully created!
Exec: /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/erts-8.1/bin/erlexec -boot /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/releases/1/cowboy_ninja_release -mode embedded -boot_var ERTS_LIB_DIR /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/erts-8.1/../lib -config /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/releases/1/sys.config -args_file /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release/releases/1/vm.args -- console
Root: /Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release
/Users/quantum/cowboy_ninja/_rel/cowboy_ninja_release
heart_beat_kill_pid = 52128
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
=INFO REPORT==== 1-Jan-2017::17:03:57 ===
application: cowboy_ninja
exited: {bad_return,
{{cowboy_ninja_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',
[{"/action",action_handler,[]},
{"/join",hello_handler,[]}]}]],
[]},
{cowboy_ninja_app,start,2,
[{file,"src/cowboy_ninja_app.erl"},{line,8}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,cowboy_ninja,{bad_return,{{cowboy_ninja_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{\"/action\",action_handler,[]},{\"/join\",hello_handler,[]}]}]],[]},{cowboy_ninja_app,start,2,[{file,\"src/cowboy_ninja_app.erl\"},{line,8}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,cowboy_ninja,{bad_return,{{cowboy_ninja_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{"/action",acti
heart: Sun Jan 1 17:03:58 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Sun Jan 1 17:03:58 2017: Would reboot. Terminating.
gmake: *** [erlang.mk:6448: run] Error 1
看起来它无法找到我的文件?这条错误信息是什么?
答案 0 :(得分:0)
您需要创建一个cowboy_ninja.app
文件并列出您正在使用的所有应用程序(牛仔等)。 Relx将查看该文件以查看它在您的发行版中需要包含哪些应用程序。
http://learnyousomeerlang.com/building-otp-applications
目前,它不会将牛仔应用程序或其中任何已编译的模块包含在您的版本中。
的示例{application, 'hello_world', [
{description, "Cowboy Hello World example"},
{vsn, "1"},
{modules, ['hello_world_app','hello_world_sup','toppage_handler']},
{registered, [hello_world_sup]},
{applications, [kernel,stdlib,cowboy]},
{mod, {hello_world_app, []}},
{env, []}
]}.
您还需要告诉relx在哪里查找您的应用程序(在您的relx.config中)。
{lib_dirs, [
"/usr/local/lib/elixir/lib/*/ebin", "./_build/prod/lib/*/ebin", "./deps/*/ebin"]}.
如果您没有为应用使用构建工具,请查看erlang.mk。它会自动为您创建一个app文件。