[erlang-questions] OTP error: bad_return
Francesco Cesarini
francesco@REDACTED
Sat Jun 14 21:07:29 CEST 2014
It is the return value which is not what the supervisor expects. It should be
{ok, {RestartStrategy, ChildList}}, you are sending {ok, RestartStrategy, ChildList}
F
> On 14 Jun 2014, at 19:08, Ben Hsu <benhsu@REDACTED> wrote:
>
>
> 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140614/1db97d58/attachment.htm>
More information about the erlang-questions
mailing list