[erlang-questions] Designing supervision trees

Alessandro Sivieri alessandro.sivieri@REDACTED
Wed May 5 13:01:43 CEST 2010


2010/5/4 Garrett Smith <g@REDACTED>

> I think you'll find different opinions here. I prefer to use
> supervisors to start and manage processes. If a process needs to
> "spawn" something, it might make sense to call add_child on an
> appropriate supervisor. You can create a custom add_xxx_child function
> on your supervisor module to act somewhat as a factory function.
>
> This lets you fire-and-forget (in particular, using
> simple_one_for_one, which can remove children when they terminate) and
> avoids messing around with trap_exits in you gen_servers.
>
>
This is very interesting, essentially because I am doing the same thing as
Bernard; but, for what I have understood from the supervisor documentation,
if I want a child to be supervised, it has to implement one of the four
behaviours, doesn't it? So, if my child doesn't do that (it is simply a
process which executes a single function in loop), how can I attach it to a
supervisor?

-- 
Sivieri Alessandro
alessandro.sivieri@REDACTED
http://www.chimera-bellerofonte.eu/
http://www.poul.org/


More information about the erlang-questions mailing list