运行牛仔应用程序时出错

pre*_*sci 2 erlang cowboy

我在启动牛仔应用程序时遇到了麻烦,它给了我以下错误.出于某种原因,牧场没有启动,虽然我已经添加了代码来启动我的应用程序中的牧场.

我看到一个新的git repo cowlib被拉了.但仍然遇到麻烦.

1> application:start(satomi).
{error,
    {bad_return,
        {{satomi_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,
                                [{port,9090}],
                                cowboy_protocol,
                                [{...}]]},
                           permanent,5000,supervisor,
                           [ranch_listener_sup]}},
                      infinity]}}}}}}

=INFO REPORT==== 12-Sep-2013::11:42:46 ===
    application: satomi
    exited: {bad_return,
             {{satomi_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,
                      [{port,9090}],
                      cowboy_protocol,
                      [{env,
                        [{dispatch,
                          [{'_',[],[{[],[],toppage_handler,[]}]}]}]}]]},
                    permanent,5000,supervisor,
                    [ranch_listener_sup]}},
                  infinity]}}}}}
    type: temporary
Run Code Online (Sandbox Code Playgroud)

以下是我的app.src

>cat satomi.app.src
    {application, satomi,
     [
      {description, ""},
      {vsn, "1"},
      {registered, []},
      {applications, [
                      kernel,
                      stdlib,
        cowboy
                     ]},
      {mod, { satomi_app, []}},
      {env, []}
     ]}.
Run Code Online (Sandbox Code Playgroud)
>cat satomi.erl
-module(satomi).

-export([start/0]).

start()->
    ok = application:start(crypto),
    ok = application:start(sasl),
    ok = application:start(ranch),
    ok = application:start(cowlib),
    ok = application:start(cowboy),
    ok = application:start(satomi).
Run Code Online (Sandbox Code Playgroud)

我想弄清楚这里出了什么问题

任何人都可以指出我可以用作模板的牛仔工作样本.我正在使用rebar来编译代码.我认为这不应该有任何区别.我使用以下命令来启动应用程序

erl -pa ./ebin ./deps/*/ebin

joh*_*hlo 7

When calling application:start(satomi) from the shell it doesn't automatically start the applications it depends on, those need to be started manually. The satomi:start/0 function you have does exactly this, so the solution is to call satomi:start() from the shell.

The reason is that application:start(satomi) will actually not call satomi:start(), it is a convenience method for starting the application and its dependencies when the application is not part of an Erlang release.

UPDATE: Since Erlang R16B02, there is also application:ensure_all_started. It starts all the dependencies automatically.