<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>