[erlang-questions] Custom supervisor

Dominic Williams erlang@REDACTED
Sat Jan 17 15:13:32 CET 2009


Hi Paul,

Paul Guyot a écrit :
> But maybe we outlook the standard supervisor and there is
> a way to figure out if a worker is started or restarted 
> by the supervisor?

I don't think OTP offers a way. However, needing to know
this is a special case of needing some state to survive
crashes. Three possibilities:

- get the state from another process
- mnesia or some other persistence

In your case, the key->worker mnesia table can be used to
work out whether a worker is restarting or not. Having the
worker access the table directly or asking the manager is a
matter of taste.

> I also realize that having a supervisor doing some work 
> is a very bad idea as it implies that the workers are 
> killed if the manager dies, which might not be desirable.

Yes. The other reason for separating supervision and work is
that you want to make sure that a supervisor is simple and
reliable, then you don't want to touch it anymore :)

Regards,

Dominic Williams
http://dominicwilliams.net

----



More information about the erlang-questions mailing list