<div dir="ltr">On Thu, Apr 12, 2018 at 4:47 PM Torben Hoffmann <<a href="mailto:torben.lehoff@gmail.com">torben.lehoff@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font face="monospace"><font face="sans-serif">Are there any subtleties that I need to cater for? Have I given enough information for this question to make sense?<br></font></font><div><font face="monospace"><font face="sans-serif"><br></font></font></div></div></blockquote><div><br></div><div>Yes:<br><br></div><div>* What is the API accessing this tree? If we start stopping the tree, how are those API calls going to behave while the tree is being closed down?<br><br></div><div>* Many such trees needs some kind of "connection draining phase" where they finish their current work, but doesn't start up new work while they are being drained.<br><br></div><div>* If you dynamically start/stop workers, then you might be able to set the number of workers to the special case of 0 and then stop the tree.<br><br></div><div>* Surely, there is a supervisor on top of `top_sup` and it it the one who needs to terminate its child. Consider that some supervisor in your application has to be "permanent/persistent" over the lifetime of the application, so you always have a point to which you can "hang" your workers. This allows you to use supervisor:terminate_child/2, but do note its documentation about restarting: your child is likely to be temporary, which means you need to have some kind of management for this if restarts happen in the system.<br><br></div><div>* Dynamic alteration of the state should be logged: "worker state was changed from 8 workers to 0", but it shouldn't report such an event as an ERROR in the syslog sense. This is INFO/NOTICE level.<br><br></div><div>Final important comment:<br><br></div><div>Do extensive tests of the failure scenario! Graceful recovery is nice, but if you don't test it somewhat, you are essentially sacrificing a goat on the altar of the god of your choice and you pray to said god that things end up being nice for you.</div><div><br><br></div></div></div>