我遵循http://maplekeycompany.blogspot.in/2012/03/very-basic-cowboy-setup.html链接,但是当我运行这个项目时,它显示我崩溃报告,告诉我牛仔start_listener()是未定义的。
=CRASH REPORT==== 12-Aug-2014::10:08:06 ===
crasher:
initial call: simple_server_http:init/1
pid: <0.66.0>
registered_name: []
exception exit: {undef,
[{cowboy,start_listener,
[http,16,cowboy_tcp_transport,
[{port,8082}],
cowboy_http_protocol,
[{dispatch,
[{'_',
[{[],simple_server_http_static,
[<<"html">>,<<"index.html">>]},
{'_',simple_server_http_catchall,[]}]}]}]],
[]},
{simple_server_http,init,1,
[{file,"src/simple_server_http.erl"},{line,45}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,306}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,239}]}]}
in function gen_server:init_it/6 (gen_server.erl, line 330)
ancestors: [simple_server_sup,<0.64.0>]
messages: []
links: [<0.65.0>]
dictionary: []
trap_exit: false
status: running
heap_size: 610
stack_size: 27
reductions: 913
neighbours:
=SUPERVISOR REPORT==== 12-Aug-2014::10:08:06 ===
Supervisor: {local,simple_server_sup}
Context: start_error
Reason: {undef,
[{cowboy,start_listener,
[http,16,cowboy_tcp_transport,
[{port,8082}],
cowboy_http_protocol,
[{dispatch,
[{'_',
[{[],simple_server_http_static,
[<<"html">>,<<"index.html">>]},
{'_',simple_server_http_catchall,[]}]}]}]],
[]},
{simple_server_http,init,1,
[{file,"src/simple_server_http.erl"},{line,45}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,306}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,239}]}]}
Offender: [{pid,undefined},
{name,simple_server_http},
{mfargs,{simple_server_http,start_link,[]}},
{restart_type,permanent},
{shutdown,5000},
{child_type,worker}]
这个错误意味着什么以及如何解决它?
这个错误消息说simple_server_http模块在第45行调用的函数cowboy:start_listener/6不存在。我已经在github上检查了cowboy模块的代码源,这个函数不存在,真的。因此,博客中的代码没有机会与当前版本的cowboy一起运行。
因为它指定使用过时的erlang版本R15B(2011年12月),也许你可以看看以前版本的cowboy: 0.6.0版本提供了这个函数 ->从github获取源代码。