[erlang-questions] to supervise or not to supervise
Mihai Balea
mihai@REDACTED
Sun Mar 22 23:11:38 CET 2009
On Mar 22, 2009, at 12:24 PM, steve ellis wrote:
> I just realized that the process that spawns my standalone
> supervisors would linked by default to the supervisors through its
> call to start_link to start the supervisors in the first place. So
> when a supervisor dies because it has reached its max restarts, the
> calling gen_server process will get an exit signal in its
> handle_info callback of {'EXIT', DeadSupervisorPid,
> reached_max_restart_intensity}. This is basic error handling stuff
> and it is where i would write my code to do something with the error.
>
> And now as I read the docs on handle_info/2 i see that that is where
> all system messages get sent which seems to answer my other question.
>
> So I think I'm on the right track. Please someone let me know if I'm
> missing something. Thanks!
You are on the right track. However, keep in mind a few things:
- You need to do this only if you need some sort of special handling
of that error condition. If you don't need to do anything with it,
except maybe some reporting, then a standard supervisor will do the
trick. Personally, I would attempt to use standard OTP behaviours
whenever I could, simply because the code was extensively tested and
can be considered error-free for all intents and purposes. However,
sometimes that is not always possible.
- If you do end up writing code to supervise your own supervisors,
make sure you handle all error conditions and shutdown sequences.
Basically, I guess what I'm trying to say is, unless you know exactly
what you're doing, it's a good idea to let OTP do its job.
Cheers,
Mihai
More information about the erlang-questions
mailing list