[erlang-questions] excute code in the supervisor when a child crashes?

Pablo Platt <>
Mon Oct 19 19:51:34 CEST 2009


>In that situation, you could just use
>supervisor:which_children to rebuild the table, I suppose.
Sounds much better.

>Of course, it would be easier to just ensure that process never dies. ;)
If there are no bugs in the module it will never die?






________________________________
From: Dave Smith <>
To: Pablo Platt <>
Cc: 
Sent: Mon, October 19, 2009 7:44:30 PM
Subject: Re: [erlang-questions] excute code in the supervisor when a child  crashes?

On Mon, Oct 19, 2009 at 11:39 AM, Pablo Platt <> wrote:
> Sounds like a good solution.
> I'll create a gen_server that will call supervisor:start_child
> then it'll monitor the pid and store it in an ETS so other clients will be
> able to send messags to the child.
> If the child exists or crashes the monitoring gen_server will delete the ETS
> record of this process.
>
> The complexity is if the monitoring process dies.
> In this case it needs to scan the whole ETS table, re-monitor all live
> process and delete records of all the dead processes.

Well, I suppose it depends on what process owns that ETS table. If
your gen_server owns the ETS table, that table will get deleted at
crash time. In that situation, you could just use
supervisor:which_children to rebuild the table, I suppose.

Of course, it would be easier to just ensure that process never dies. ;)

D.



      


More information about the erlang-questions mailing list