Comments on: Using Supervisors to Keep ErlyBank Afloat http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/ Linking You to Erlang Sun, 22 May 2011 00:00:26 +0000 http://wordpress.org/?v=2.6.1 By: David Weldon http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-181 David Weldon Sat, 04 Oct 2008 22:27:06 +0000 http://spawnlink.com/?p=87#comment-181 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([]) -> process_flag(trap_exit, true), to eb_server.erl. Did Kevin get it wrong on this one? 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([]) ->
process_flag(trap_exit, true),

to eb_server.erl. Did Kevin get it wrong on this one?

]]>
By: Mitchell http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-93 Mitchell Wed, 17 Sep 2008 15:46:01 +0000 http://spawnlink.com/?p=87#comment-93 Jeremy, 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. 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! Jeremy,

Right, this is a good question. The technique I use is to use the gen_event:add_sup_handler/3 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!

]]>
By: Jeremy http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-85 Jeremy Wed, 17 Sep 2008 01:48:03 +0000 http://spawnlink.com/?p=87#comment-85 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? 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?

]]>
By: Mitchell http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-71 Mitchell Sun, 14 Sep 2008 02:40:14 +0000 http://spawnlink.com/?p=87#comment-71 I fixed the error you caught! Awesome, thanks ;) And I'm glad the series has been helpful! I fixed the error you caught! Awesome, thanks ;) And I’m glad the series has been helpful!

]]>
By: Jonathon Mah http://spawnlink.com/articles/using-supervisors-to-keep-erlybank-afloat/#comment-64 Jonathon Mah Sat, 13 Sep 2008 23:00:20 +0000 http://spawnlink.com/?p=87#comment-64 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. 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.

]]>