[erlang-questions] excute code in the supervisor when a child crashes?
Mon Oct 19 22:21:28 CEST 2009
On Oct 19, 2009, at 1:39 PM, 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.
The problem with that is if the ETS table is owned by the monitoring
process, it will go down with it.
You might want to try an already existing solution, such as Ulf
Wiger's proc/grpoc. It's basically the same idea, just that the code
has already been in use for a while, so it should be relatively solid.
In addition, gproc works in a clustered environment, if your
requirements include that.
More information about the erlang-questions