supervisor:restart_child/2

Ulf Wiger etxuwig@REDACTED
Fri Feb 23 14:58:16 CET 2001


On Fri, 23 Feb 2001, Sean Hinde wrote:

>Ulf>
>
>> When I call 
>> 
>> supervisor:terminate_child(ThisSuper, ThatChild),
>> supervisor:restart_child(ThisSuper, ThatChild).
>> 
>> Then the supervisor doesn't count this towards the restart 
>> frequency. That is, I can do this forever, and the supervisor will
>> never escalate.
>
>Seems reasonable to me. Presumably the assumption is that as you are
>explicitly calling these functions you are in control of things
>therefore it is not a fault condition. Is it?

Well, I'm not sure... (:

The reason I even care is that I have re-written supervisor so that 
it is able to tell the child how many times it has restarted, and
by extension, whether it is starting for the first time, or whether
it is, for example, an escalated restart.

In this context, what does it mean when someone explicitly 
terminates a child and restarts it? Shouldn't I update the count of
how many times it's restarted? And if I do, shouldn't I terminate 
the supervisor if the restart intensity is exceeded?

One alternative is to pretend as if nothing has happened. This will,
of course, not fool the child -- it will know that _something_
happened...

Another alternative is to reset the restart count. This might have
surprising effects.

My guess is that if you're going to explicitly terminate and restart a
child, you're probably only going to do it once in a fortnight or so,
so it most likely won't matter. So, I made restart_child/2 also update
the restart count. This means that it can also trigger an escalated
restart.



My hacked supervisor.erl and the hacked behaviour modules seem to
work just fine. I can't post them, as the archive is too large, but if
anyone wants to check them out, let me know.

BTW, I've also rewritten the supervisor to use monitor instead of
links (actually, it uses both), so now a child can't mess up the
supervision by explicitly unlinking.


/Uffe
-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB





More information about the erlang-questions mailing list