[erlang-questions] Associating contextual info with monitors

Vance Shipley vances@REDACTED
Tue Feb 19 20:55:51 CET 2008


On Tue, Feb 19, 2008 at 01:54:39PM -0500, Dave Rafkind wrote:
}  The gen_server manages all the state and brings up and shuts down the
}  other processes. So far it seems like I should start the supervisor with
}  just the manager under it, and then store the supervisor's Pid in the
}  manager, and then let the manger dynamically add and remove children
}  from the supervisor when appropriate.
  
I use exactly that system quite often.

}  However, this seems a bit awkward, the supervisor and the manager should
}  be combined in some way; is this possible? (can a module have 2
}  behaviours?) Or is there a better way to do it?

It is quite possible to use more than one behaviour model attribute
in a module however you can't combine supervisor and gen_server as
they both need an init/1 callback and in general conflict.

You can always write your own supervisor if you are dissatisfied
with what OTP provides.  You'd best know what you are doing though.

I suspect that one day I will create my own supervisor to handle 
supervision trees which span multiple nodes.  Such a supervisor
needs application specific handling as you have to consider what 
to do when you get a {nodedown, Node} message.  Is that child dead
or just "in a tunnel" to use a cellular analogy?

	-Vance




More information about the erlang-questions mailing list