I have an Erlang app where I have a simple_one_for_one
supervisor that supervises a set of processes that watch for changes on web pages (one URL per child).
I start the children that should be active in my application behaviour's start
function, after having added the supervisor in question to the app's top supervisor (along with some other processes). Children are then started and stopped dynamically as entries are added/removed (and the entries are persisted to a DB).
If this simple_one_for_one
supervisor crashes because too many of its children crash (e.g. due to a network issue), the supervisor itself is restarted, but its children are lost. At this point I want to check the DB and start the children that should be active again.
But, how should I restart the children? How can I tell that the supervisor restarted? Should I schedule starting the children from the supervisor's own start_link
function? Is there a better way to design this?
simple_one_for_one
supervisor (I already do – aone_for_one
supervisor that also supervises some other things), how should that supervisor know when to restart thesimple_one_for_one
supervisor's children? – beta