<div>
            <div>
                <span>Yeah, that makes perfect sense and would obviously solve the problem.<br>
                </span></div><div><span><br></span></div><div>
                <span>The reason we'd gone down this path was that we had a number of "sub" processes (the gen_event just being one example) that we felt would be "polluting" the supervisor; these sub-processes were just helpers of the primary gen_servers that the supervisor was controlling - using a start_link in the primary gen_servers felt like a very clean and easy way of spinning up these other processes in a way that (we thought) would still be resilient to failures.<br><div><br></div><div>The thing that bit us was that we naively thought that, due to the sub-process being linked, it would die when the parent died.  Of course, it does, but its death is asynchronous to the notification that the supervisor receives and hence it may well still be alive (doomed, but alive) when the supervisor begins the restart cycle.  Our servers don't crash that often, and when they do this race condition is was rarely seen, which was reinforced our misconceptions.  The only thing that does surprise me is how many times the supervisor can go round the restart loop before the doomed process finally exits - we have seen it thrash round this loop about 1000 times before the supervisor itself finally fails; I guess it's just down to how things are being scheduled by the VM, and in those cases we were just getting unlucky.</div><div><br></div><div>Sounds like best-practice within the OTP world is to have everything started via a supervisor - is that a fair comment?</div><div><br></div><div>Cheers,</div><div><br></div><div>Steve</div><div><br></div>-- <br>Steve Strong, Director, id3as<br><div>twitter.com/srstrong</div><br></span></div><div>
                
                <p>On Wednesday, 1 June 2011 at 23:57, Ahmed Omar wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div>Agree with Roberto, you should put under supervisor. Regarding your case, i would guess you are trapping exit in your init in my_gen_event?<br><br><div>On Wed, Jun 1, 2011 at 11:15 PM, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com">roberto@widetag.com</a>></span> wrote:<br><blockquote type="cite"><div>hi steve,<br><br>your gen_event should be started by your supervisor too. in this case, since you specified a one_for_all behaviour, when gen_server crashes, gen_event will be restarted too.<br>
<font color="#888888"><br>r.<br><br>
</font><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></div></blockquote></div><br><br clear="all"><br>-- <br>Best Regards,<br>- Ahmed Omar<div><a href="http://nl.linkedin.com/in/adiaa" target="_blank">http://nl.linkedin.com/in/adiaa</a></div><div>Follow me on twitter</div><div>
<a href="http://twitter.com/#!/spawn_think" target="_blank">@spawn_think</a></div><br>
</div></div></span>
                
                
                
                
                </blockquote>
                
                <div>
                    <br>
                </div>
            </div>
        </div>