[erlang-questions] terminate supervisor from it's child process

block.rxckin.beats@REDACTED block.rxckin.beats@REDACTED
Thu Feb 14 09:16:51 CET 2019


Hi Vance

thanks for your advice !

> However that would have the side effect of kill stun_worker and
srtp_worker when dtls_worker exited.
that's expected, because they share same socket which timeouted.

> Yes, exit the child and have the supervisor's restart strategy do it's
job.
> You could set the restart strategy of the above udp_sup to be 'rest_for_one'
which would kill all the other workers when it died.

I don't wanna restart child workers, so make it `restart => temporary` in
childspec.
but in that case, if udp_woker terminates, udp_sup doesn't terminate. only
igore it.

make if make `restart => permanent` and sup flag like below

```
SupFlags = #{
      strategy  => rest_for_one, # same for one_for_all
      intensity => 0,
      period    => 1
},
```
that's terminates supervisor with ErrorReport with
reached_max_restart_intensity.

it's terminates all supervision tree include udp_sup as I expected
but I don't intent to restart, only shutdown like temporary :(


> The right way is to have a seperate supervisor for
[dtls|stun|srtp]_worker as a sibling to udp_worker.

I think you mean like this.

udp_sup - udp_worker
               |- dtls_sup - dtls_woker
               .... (same for stun,srtp)

if udp_worker be temporary, udp_sup will ignore,
if udp_wokrer be permanent and intensity = 0, period = 1
udp_sup will terminate with error because of restart error (even if I don't
intent to restart)


if I misreading something, please mention me.

thanks
Jxck








2019年2月14日(木) 15:53 Vance Shipley <vances@REDACTED>:

> On Thu, Feb 14, 2019 at 11:52 AM block.rxckin.beats@REDACTED
> <block.rxckin.beats@REDACTED> wrote:
> > I'm writing udp server with supervision tree like below.
> ...
> >               (s1for1)      (1for1)
> > server_sup - udp_sup -  |- udp_worker
> >                                        |- dtls_worker
> >                                        |- stun_worker
> >                                        |- srtp_worker
>
> > is there any way to terminate supervisor from it's child process ?
>
> Yes, exit the child and have the supervisor's restart strategy do it's job.
>
> > or any other recommended process architecture for UDP server ?
>
> You could set the restart strategy of the above udp_sup to be
> 'rest_for_one' which would kill all the other workers when it died.
> However that would have the side effect of kill stun_worker and
> srtp_worker when dtls_worker exited.
>
> The right way is to have a seperate supervisor for
> [dtls|stun|srtp]_worker as a sibling to udp_worker.
>
>
> --
>      -Vance
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190214/32c635c7/attachment.htm>


More information about the erlang-questions mailing list