[erlang-questions] simple_one_for_one supervisor - what happens at restart? (also: gen_tcp)
Sat May 14 09:46:00 CEST 2016
On 14 May 2016 at 00:59, Ryan Stewart <> wrote:
> Oliver: there is no restart for children under a simple 1-1 supervisor as
> documented under Supervision Principles at
> Otoh, I have to strongly disagree with Chandru about there being "no
> point" in supervising a connection process. Depending on the nature of your
> application, there can be a *huge* benefit in supervision, which is orderly
> shutdown. With a proper supervisory tree, you can ensure that all
> connection processes have a chance to finish their work and shut down
> cleanly when you stop your application.
Cleanup can be done in the terminate callback if you use
process_flag(trap_exit, true). You need to supervise a process primarily if
you want it *restarted*, not for cleanup. Yes, you do have orderly shutdown
mechanisms if the number of restarts exceed a "normal" value, but that is
not the situation here.
Oliver has a server process to which clients connect. He does not need a
supervisor for this because it is up to the client to reconnect if a
connection is lost.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions