[erlang-questions] OTP error: bad_return

Ben Hsu benhsu@REDACTED
Sat Jun 14 20:08:52 CEST 2014


Hello,

I am trying to put my application under an OTP supervisor, and I'm seeing
an error message I don't understand when I start my application using
"application:start(app_name)".

The error says "bad_return", and I'm not sure if it means the tuple I'm
returning from init/1 is bad, or if my code is bad.

My supervisor code, which I took verbatim from the OTP book, looks like
this:

start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).

init([]) ->
    Server = {stats_gatherer, {stats_gatherer, start_link, []},
              permanent, 2000, worker, [stats_gatherer]},
Children = [Server],
RestartStrategy = {one_for_one, 0, 1},
{ok, RestartStrategy, Children}.


I tried running stats_gatherer:start_link() from the Erlang shell, and it
worked.

The error message is below. I would be grateful for any insight.

1> application:start(stats_app).
{error,
    {{error,
         {bad_return,
             {stats_sup,init,
                 {ok,{one_for_one,0,1},
                     [{stats_gatherer,
                          {stats_gatherer,start_link,[]},
                          permanent,2000,worker,
                          [stats_gatherer]}]}}}},
     {stats_app,start,[normal,[]]}}}

=INFO REPORT==== 14-Jun-2014::14:03:19 ===
    application: stats_app
    exited: {{error,
                 {bad_return,
                     {stats_sup,init,
                         {ok,{one_for_one,0,1},
                             [{stats_gatherer,
                                  {stats_gatherer,start_link,[]},
                                  permanent,2000,worker,
                                  [stats_gatherer]}]}}}},
             {stats_app,start,[normal,[]]}}
    type: temporary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140614/623b694e/attachment.htm>


More information about the erlang-questions mailing list