<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Yes you're right, now that I re-read my question it's not particularly relevant.</p>
<p><br>
</p>
<p>worker_sup will not be restarted by super_sup if the max restarts for poolboy pool is reached.</p>
<p><br>
</p>
<p>A caller will call:</p>
<p>start_pool_link(Opts)</p>
<p>This triggers the super_sup to start a worker_sup which starts poolboy. </p>
<p>The caller is linked to worker_sup, so if it goes down (because it dies or because the max restart is reached) the caller will also go down.</p>
<p>If the caller goes down, the pool_managager which is monitoring the caller will take worker_sup down with exit(WorkerSupPid, shutdown). Resorting to the monitor is because worker_sup won't go down when the caller exits. </p>
<p><br>
</p>
<p>This is so that in the situation where either the caller or the pool goes down all processes are cleaned up. </p>
<p><br>
</p>
<p>Let me know if you need any further clarification.</p>
<p><br>
</p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Sean Cribbs <seancribbs@gmail.com><br>
<b>Sent:</b> Tuesday, 1 December 2015 10:58 a.m.<br>
<b>To:</b> David Leach<br>
<b>Cc:</b> Erlang Questions<br>
<b>Subject:</b> Re: [erlang-questions] Supervision question</font>
<div> </div>
</div>
<div>
<div dir="ltr">If I'm reading this correctly, your worker_sup will be restarted after the max_restarts is reached for the poolboy pool. This means that the caller can link or monitor worker_sup, correct? Or do you need a one_for_all strategy?
<div><br>
</div>
<div>I have a suspicion dependencies (link/monitor) and discovery (gproc, registered names) are also being confused or conflated in your question.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Nov 30, 2015 at 3:25 PM, David Leach <span dir="ltr">
<<a href="mailto:dleach@wetafx.co.nz" target="_blank">dleach@wetafx.co.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi All,</p>
<p><br>
</p>
<p>We have an application that starts pools of different kinds of workers and we want to offer the caller the ability to "link" to a pool of workers. We're using poolboy to manage the pools and gproc for naming the pools and ensuring startup is complete before
 returning a reference to the caller. We don't want to link to poolboy, because it can and should be restarted by the supervisor supervising it. The behavior we want is, if the supervisor managing poolboy reaches its maximum restarts  the caller who is linked
 also dies. We also want that pool to disappear if the caller dies and the caller can restart it again. Structure looks a little like this:</p>
<p><br>
</p>
<p><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>   pool_manager</span><br>
</p>
<p>super_sup -> worker_sup -></p>
<p><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>    </span><span>   poolboy</span><br>
</p>
<p><span><br>
</span></p>
<p>Right now, the caller is linked to the worker_sup so that if the worker_sup goes down caller also goes down. The pool_manager monitors the caller and sends exit(WorkerSupPid, shutdown) if the caller goes down so that the pool gets cleaned up.</p>
<p><br>
</p>
<p>Is there a better way of doing this? Better being easier for someone reading the code to understand quickly or more reliably if there is a problem with this implementation? </p>
<p><br>
</p>
<p>We thought about having the super_sup start two children, one of them performing the role of the pool_manager in this situation . But that seems a bit excessive, and how might one name it clearly to differentiate the roles of the pool_manager and it. The
 pool manager takes care of details of the pool and translates the reference the caller has to a pid.</p>
<p><br>
</p>
<p>Thanks in Advance,</p>
<p><br>
</p>
<p>David</p>
</div>
</div>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>