<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Using Supervisors to Keep ErlyBank Afloat</title>
	<atom:link href="http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/feed/" rel="self" type="application/rss+xml" />
	<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/</link>
	<description>Linking You to Erlang</description>
	<pubDate>Thu, 29 Jul 2010 20:02:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: David Weldon</title>
		<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-181</link>
		<dc:creator>David Weldon</dc:creator>
		<pubDate>Sat, 04 Oct 2008 22:27:06 +0000</pubDate>
		<guid isPermaLink="false">http://spawnlink.com/?p=87#comment-181</guid>
		<description>As I'm writing this I'm watching Kevin Smith's "Erlang in Practice" episode 8. In it he claims that you need to explicitly trap exits in order for a supervisor to notice that something has gone wrong. In our example we would add: 

init([]) -&#62;
    process_flag(trap_exit, true),

to eb_server.erl. Did Kevin get it wrong on this one?</description>
		<content:encoded><![CDATA[<p>As I&#8217;m writing this I&#8217;m watching Kevin Smith&#8217;s &#8220;Erlang in Practice&#8221; episode 8. In it he claims that you need to explicitly trap exits in order for a supervisor to notice that something has gone wrong. In our example we would add: </p>
<p>init([]) -&gt;<br />
    process_flag(trap_exit, true),</p>
<p>to eb_server.erl. Did Kevin get it wrong on this one?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mitchell</title>
		<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-93</link>
		<dc:creator>Mitchell</dc:creator>
		<pubDate>Wed, 17 Sep 2008 15:46:01 +0000</pubDate>
		<guid isPermaLink="false">http://spawnlink.com/?p=87#comment-93</guid>
		<description>Jeremy,

Right, this is a good question. The technique I use is to use the &lt;a href="http://www.erlang.org/doc/man/gen_event.html#add_sup_handler-3" rel="nofollow"&gt;gen_event:add_sup_handler/3&lt;/a&gt; method. Its not as simple as throwing something into a supervision tree but at least using that method your handler will receive messages if the event handler crashes or if the handler somehow went bad. 

Using these messages you can reattach the event handler as soon as the event server re-registers itself. Although theoretically this would require a timer to check if the event server is up, in my project its always been back up almost instantaneously. But to be safe, you should implement a timer that tries adding itself to the event server every two seconds or so. 

Also be sure if you do use this that you add some logic to make sure that it doesn't retry to connect forever and that it caps out at some point :)

This is what I do but I haven't seen any "official" word on how to do it so if any of the other readers has a better way of doing this, I'd greatly appreciate it!</description>
		<content:encoded><![CDATA[<p>Jeremy,</p>
<p>Right, this is a good question. The technique I use is to use the <a href="http://www.erlang.org/doc/man/gen_event.html#add_sup_handler-3" rel="nofollow">gen_event:add_sup_handler/3</a> method. Its not as simple as throwing something into a supervision tree but at least using that method your handler will receive messages if the event handler crashes or if the handler somehow went bad. </p>
<p>Using these messages you can reattach the event handler as soon as the event server re-registers itself. Although theoretically this would require a timer to check if the event server is up, in my project its always been back up almost instantaneously. But to be safe, you should implement a timer that tries adding itself to the event server every two seconds or so. </p>
<p>Also be sure if you do use this that you add some logic to make sure that it doesn&#8217;t retry to connect forever and that it caps out at some point <img src='http://spawnlink.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is what I do but I haven&#8217;t seen any &#8220;official&#8221; word on how to do it so if any of the other readers has a better way of doing this, I&#8217;d greatly appreciate it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-85</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Wed, 17 Sep 2008 01:48:03 +0000</pubDate>
		<guid isPermaLink="false">http://spawnlink.com/?p=87#comment-85</guid>
		<description>These tutorials have been immensely helpful. I appreciate them very much. I do have one question concerning the supervisor and the event manager. Using the supervisor, how should event handlers be registered? Particularly, how should the eb_withdrawal_handler be registered? Obviously, it can be done in the repl, but how would this be done in a running system?</description>
		<content:encoded><![CDATA[<p>These tutorials have been immensely helpful. I appreciate them very much. I do have one question concerning the supervisor and the event manager. Using the supervisor, how should event handlers be registered? Particularly, how should the eb_withdrawal_handler be registered? Obviously, it can be done in the repl, but how would this be done in a running system?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mitchell</title>
		<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-71</link>
		<dc:creator>Mitchell</dc:creator>
		<pubDate>Sun, 14 Sep 2008 02:40:14 +0000</pubDate>
		<guid isPermaLink="false">http://spawnlink.com/?p=87#comment-71</guid>
		<description>I fixed the error you caught! Awesome, thanks ;) And I'm glad the series has been helpful!</description>
		<content:encoded><![CDATA[<p>I fixed the error you caught! Awesome, thanks <img src='http://spawnlink.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> And I&#8217;m glad the series has been helpful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathon Mah</title>
		<link>http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-64</link>
		<dc:creator>Jonathon Mah</dc:creator>
		<pubDate>Sat, 13 Sep 2008 23:00:20 +0000</pubDate>
		<guid isPermaLink="false">http://spawnlink.com/?p=87#comment-64</guid>
		<description>Thanks again, Mitchell! I'm really taking a lot away from your series.

Errata: The event manager child spec uses "[eb_event_manager]" in the first occurrence, but "dynamic" in init/1.</description>
		<content:encoded><![CDATA[<p>Thanks again, Mitchell! I&#8217;m really taking a lot away from your series.</p>
<p>Errata: The event manager child spec uses &#8220;[eb_event_manager]&#8221; in the first occurrence, but &#8220;dynamic&#8221; in init/1.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
