[erlang-questions] simple_one_for_one supervisor - what happens at restart? (also: gen_tcp)

Chandru <>
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
> http://erlang.org/doc/man/supervisor.html#id243029
>
> 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.

cheers,
Chandru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160514/a17538e9/attachment.html>


More information about the erlang-questions mailing list