Reputation: 337
I'm trying run this cowboy example using rebar3: cowboy version 2.0.0-pre.5
What I do is:
rebar3 new app hello_world
{cowboy,".*", {git, "https://github.com/ninenines/cowboy", {branch, "master"}}}
rebar3 compile
. Everything go fineerl -pa _build/default/lib/*/ebin
application:start(hello_world).
then error occurs
{error,{bad_return,{{hello_world_app,start,[normal,[]]},
{'EXIT',{noproc,{gen_server,call,
[ranch_sup,
{start_child,{{ranch_listener_sup,http},
{ranch_listener_sup,start_link,
[http,100,ranch_tcp,
[{connection_type,supervisor},{port,...}],
cowboy_clear,
#{connection_type => supervisor,...}]},
permanent,infinity,supervisor,
[ranch_listener_sup]}},
infinity]}}}}}}
=INFO REPORT==== 24-Jan-2017::18:34:52 ===
application: hello_world
exited: {bad_return,
{{hello_world_app,start,[normal,[]]},
{'EXIT',
{noproc,
{gen_server,call,
[ranch_sup,
{start_child,
{{ranch_listener_sup,http},
{ranch_listener_sup,start_link,
[http,100,ranch_tcp,
[{connection_type,supervisor},
{port,8080}],
cowboy_clear,
#{connection_type => supervisor,
env => #{dispatch => [{'_',[],
[{[],[],toppage_handler,
[]}]}]}}]},
permanent,infinity,supervisor,
[ranch_listener_sup]}},
infinity]}}}}}
type: temporary
It seems that runch_sup can't start. What's wrong with my approach? I want to run exactly the same src code as in example.
Upvotes: 1
Views: 588
Reputation: 495
For anyone else stuck on this issue you just need to make sure ranch
is started before your application is started. To do this edit the src/my_app.app.src
file like so:
{application, my_app,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, {my_app_app, []}},
{applications,
[kernel,
stdlib,
ranch
]},
{env,[]},
{modules, []},
{licenses, ["Apache-2.0"]},
{links, []}
]}.
Notice that ranch
has been added as an application after kernel
and stdlib
.
Upvotes: 1