[erlang-questions] Managing children

Mihai Balea mihai@REDACTED
Sun Oct 16 22:15:35 CEST 2011


On Oct 16, 2011, at 3:54 PM, Bob Cowdery wrote:

> Hi
> 
> I have an OTP system with one supervisor that starts 7 processes. When
> all processes are running I need to do some initialisation by sending
> event messages from an ets database.
> 
> What would be the appropriate way to achieve this. I don't see anything
> specifically in supervisor that helps.
> 
> 1. I could make the last process to start make the call, but that's a fudge.
> 2. I could send a message from every process at the end of its init/1 to
> a monitor process and get it to make the call when everything has
> started, but that seems like duplicating supervisor function.
> 3. I could run a process inside my supervisor module to either do what
> (2) does or maybe call count_children/1 until I see all processes active.
> 
> Is there some reason why supervisor does not have callbacks for managing
> children.

The supervisor's start_link function will only return {ok, pid()} when all children are up and running.
You can start sending your event messages after that.

Mihai




More information about the erlang-questions mailing list