1

我正在尝试使用 rebar3 运行这个牛仔示例:cowboy version 2.0.0-pre.5

我要做的是:

  1. rebar3 new app hello_world
  2. 将示例 src 复制到我的 src
  3. 更新 rebar.config{cowboy,".*", {git, "https://github.com/ninenines/cowboy", {branch, "master"}}}
  4. rebar3 compile. 一切顺利
  5. erl -pa _build/default/lib/*/ebin
  6. application:start(hello_world).

然后发生错误

{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

似乎 runch_sup 无法启动。我的方法有什么问题?我想运行与示例完全相同的 src 代码。

4

1 回答 1

0

Ranch 1.3 默认依赖于 ssl 应用程序。如果您不启动它,Ranch 将无法启动。我建议在执行 ok = application:start(App) 时匹配 ok,您会更快地知道这个问题。

埃森_

是问题

于 2017-01-25T09:41:25.150 回答