Starting dynamic users simple_one_for_one after starting the supervisor

I have a named Supervisorone that oversees many simple_one_for_oneworkers who do the job at regular intervals for each user on my system.

I want the application to run one worker for each user the Supervisorfirst time it starts, and I want the application to do the same if it Supervisorrestarts later, for any reason.

Currently, I start all children dynamically in a callback Application start(type, args), but if it reboots Supervisor, this will not cause all child processes to start.

How to ensure that all dynamic child workers start immediately after start / restart Supervisor?

(My application is in Elixir, but the same principles apply to Erlang.)

+4
source share
1 answer

One way to do this, which works very well, is to use a different supervisor and "restart working." Your supervisor - the child of the new - is the brother of the reboot worker. The new supervisor uses one_for_allor rest_for_one, so if your supervisor dies, it reboots and reboots.

When a working restart restarts, it can start dynamic workers.

+6
source

All Articles