为什么我的牛仔服务器没有运行?

为什么我的牛仔服务器没有运行?

问题描述:

我试图运行我的服务器。我将我的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:. 

猫的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 

它看起来像无法找到我的文件?这个错误信息是什么意思?

您需要创建一个cowboy_ninja.app文件并列出您正在使用的所有应用程序(牛仔等)。 Relx会查看该文件,以查看它需要包含在您的版本中的哪些应用程序。

http://learnyousomeerlang.com/building-otp-applications

目前,它不包括牛仔应用程序或任何它编译的模块到您的释放。

这里是the cowboy examples

{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。它会自动为您创建一个应用程序文件。

+0

你好,我仍然有这个问题:https://*.com/questions/46492630/kernel-pid-terminated-application-start-failure-bad-return – quantumpotato