<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>It is the return value which is not what the supervisor expects. It should be</div><div><br></div><div>{ok, {RestartStrategy, ChildList}}, you are sending {ok, RestartStrategy, ChildList}</div><div><br></div><div>F<br><br><div><br></div></div><div><br>On 14 Jun 2014, at 19:08, Ben Hsu <<a href="mailto:benhsu@gmail.com">benhsu@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Hello,</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">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)".</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">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.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">My supervisor code, which I took verbatim from the OTP book, looks like this:</font></div><div><font face="courier new, monospace"><br>
</font></div><div><div><font face="courier new, monospace">start_link() -></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>supervisor:start_link({local, ?SERVER}, ?MODULE, []).</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">init([]) -></font></div><div><font face="courier new, monospace"> Server = {stats_gatherer, {stats_gatherer, start_link, []},</font></div>
<div><font face="courier new, monospace"> permanent, 2000, worker, [stats_gatherer]},</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>Children = [Server],</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>RestartStrategy = {one_for_one, 0, 1},</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>{ok, RestartStrategy, Children}.</font></div>
</div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">I tried running stats_gatherer:start_link() from the Erlang shell, and it worked.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">The error message is below. I would be grateful for any insight.</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">1> application:start(stats_app).</font></div><div><font face="courier new, monospace">{error,</font></div><div><font face="courier new, monospace"> {{error,</font></div>
<div><font face="courier new, monospace"> {bad_return,</font></div><div><font face="courier new, monospace"> {stats_sup,init,</font></div><div><font face="courier new, monospace"> {ok,{one_for_one,0,1},</font></div>
<div><font face="courier new, monospace"> [{stats_gatherer,</font></div><div><font face="courier new, monospace"> {stats_gatherer,start_link,[]},</font></div><div><font face="courier new, monospace"> permanent,2000,worker,</font></div>
<div><font face="courier new, monospace"> [stats_gatherer]}]}}}},</font></div><div><font face="courier new, monospace"> {stats_app,start,[normal,[]]}}}</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">=INFO REPORT==== 14-Jun-2014::14:03:19 ===</font></div><div><font face="courier new, monospace"> application: stats_app</font></div><div><font face="courier new, monospace"> exited: {{error,</font></div>
<div><font face="courier new, monospace"> {bad_return,</font></div><div><font face="courier new, monospace"> {stats_sup,init,</font></div><div><font face="courier new, monospace"> {ok,{one_for_one,0,1},</font></div>
<div><font face="courier new, monospace"> [{stats_gatherer,</font></div><div><font face="courier new, monospace"> {stats_gatherer,start_link,[]},</font></div><div>
<font face="courier new, monospace"> permanent,2000,worker,</font></div><div><font face="courier new, monospace"> [stats_gatherer]}]}}}},</font></div><div>
<font face="courier new, monospace"> {stats_app,start,[normal,[]]}}</font></div><div><font face="courier new, monospace"> type: temporary</font></div><div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>erlang-questions mailing list</span><br><span><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></span><br><span><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br></div></blockquote></body></html>