为什么我的牛仔服务器无法运行? [英] Why is my cowboy server not running?
问题描述
我正在尝试运行服务器。我将src文件复制到全新的牛仔安装中,这是我遇到的错误。
I'm trying to run my server. I copied my src files into a fresh cowboy install, this is the error I'm getting.
~/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
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
它看起来找不到我的文件?错误消息是什么?
It looks like it can't find my files? What is this error message saying?
推荐答案
您需要创建 cowboy_ninja.app
文件并列出您正在使用的所有应用程序(牛仔等等)。 Relx将查看该文件,以查看它需要包含在您的发行版中的应用程序。
You need to create a cowboy_ninja.app
file and list all the applications you are using (cowboy, etc.). Relx will look at that file to see which applications it needs to include in your release.
http://learnyousomeerlang.com/building -otp-applications
当前它不包含牛仔版应用程序或其任何已编译的模块。
Currently it is not including the cowboy application or any of it's compiled modules into your release.
这是来自
{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中)。
You also need to tell relx where to look for your applications (in your relx.config).
{lib_dirs, [
"/usr/local/lib/elixir/lib/*/ebin", "./_build/prod/lib/*/ebin", "./deps/*/ebin"]}.
如果您的应用程序未使用构建工具,请查看 erer.mk 。它会自动为您创建一个应用文件。
If you are not using a build tool for your app take a look at erlang.mk. it automatically creates an app file for you.
这篇关于为什么我的牛仔服务器无法运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!