#Any good library for monitoring a bunch of processes with one process?

1 messages · Page 1 of 1 (latest)

last quest
#

Currently I have a use case where a Live View process can created a number of child processes that the user will interact with. These child processes are created using a DynamicSupervisor because I want them to restart if they ever encounter an error.

What I want is that when the Live View process terminates, All the children are removed from the dynamic supervisor. I figure you could do this my having a single GenServer that monitors the live view process and terminates the child processes when the live view dies. Is there a library out there that already does this? Registry gets most of the way there, but i haven't found a way to get the Registry to listen to DOWN events. I don't think this would be hard to write, I'd just like to avoid it if something mature already exists. Thanks!

covert heart
#

You could start your supervisor with a linked process of some sort. It will die when the LiveView dies.

#

There's also a lib called Parent that gives a higher degree of control than DynamicSupervisor but you can do what you're saying with a linked process.

teal mulch
#

seems like if all those individual processes just monitor the liveview process, the could get the DOWN message and terminate themselves

last quest
#

They can only terminate themselves if they are running with restart: :transient. I've tried that, and it works, but I don't think I'm getting the restart behaviour that I'm after. The process hasn't been restarting itself the way I expected.

I don't want to just link the processes to the live view because the process itself might crash, and i dont want to crash the live view, I'd rather just handle the error gracefully and what for the crashed process to restart.