[erlang-questions] Custom supervisor

Dominic Williams <>
Sat Jan 17 10:52:22 CET 2009


Hi Paul,

Paul Guyot a écrit :
 > [...]
> Is there a more OTP-way to perform this, i.e. to track the death/ 
> restarts of the children of a supervisor?

In the OTP approach, you should not mix supervision with 
work. Your manager is doing work, so it should not be a 
supervisor as well.

One solution would be for the manager to attach the workers 
as dynamic childs to its own supervisor. This would be if 
the number of workers is variable.

If the number of workers is fixed, everyone (manager and 
workers) could be declared as fixed children in the same 
supervisor.

Both of the above approaches are right if the restart 
strategies are the same for manager and workers, though, 
which is rarely the case. The "standard" solution in your 
kind of case is to have a top supervisor that supervises the 
manager and another supervisor. The sub-supervisor 
supervises all the workers. You'd probably need to have the 
workers register themselves with the manager when they start 
or restart.

Hope that helps,

Dominic Williams
http://dominicwilliams.net

----



More information about the erlang-questions mailing list