Supervision Trees - A Beginner Writes

Bengt Kleberg Bengt.Kleberg@REDACTED
Thu Jan 15 13:33:08 CET 2004


Gordon Guthrie, BTP, BT, SE wrote:
> Folks
> 
> I am writing my first supervision tree. I have an application which starts a
> simple one-for-one supervisor.
> 
is this a ''one-for-one'' supervisor that happens to be simple? or is it 
''simple-one-for-one'' as per OTP Design Principles, 5.9 
(http://erlang.org/doc/r9c/doc/design_principles/part_frame.html).


> This supervisor starts workers. The intention is that each worker will
> eventually handle an http session, so I am starting them as transients.
> These processes will die when the user session they support times out, so
> each worker spawns a linked timeout process which periodically messages its
> worker "if you haven't done anything since last time then exit".
> 
> The problem I have is that when the worker exits (either normal or a custom
> timeout message) the supervisor and then the application both exit.

according to the manual a transient child process should behave differently
it it exits with an abnormnal exit (vs a normal exit). are you getting the
same thing?


> I can see that there might be circumstances that would kill a worker in
> which a supervisor might also want to terminate for a clean restart.

it is only if you have more than MaxR number of restarts occur in the 
last MaxT seconds (as per OTP Design Principles, 5.4), that the 
supervisor terminates. or if the supervisiors supervisior terminates...


> So my question is how do I (under OTP) handle the exit message that results
> from the spawn_link to the child. In a 'homebrew' supervision tree (ie last
> week) I would have just trapped exits...

imho the supervision behaviour should handle this for you.


bengt



More information about the erlang-questions mailing list