[erlang-questions] Applications, supervisors, and servers, oh my

David Welton <>
Sat Jun 12 02:26:03 CEST 2010


With thanks to Bernard for his answers, I'm still struggling with how
to structure an application in the proper way.

To be very concrete about what I'm doing, I'm working on some code
that combines twitter, irc, and the web, in the form of:

http://github.com/davidw/erlang_twitter
http://github.com/gdamjan/erlang-irc-bot
and mochiweb

I've run into several things that I'm simply unsure of:

1) Should I make each of those parts an "application" (in the Erlang
sense) unto itself?  If so, who starts all of them, and where in the
code?

2) Should I call into their supervisor code and make a "supervision
tree" that way?  Experimentation indicates that applications run on
their own and don't seem amenable to being added underneath a
supervisor, which means that if they crash, I can't tell the whole
system to go down as I might with an one_for_all in the supervisor.

3) I'm still not sure of the best patterns for passing things
around...  For instance, I need to tell the twitter code which ID's to
follow, which involves some lookups. If the twitter code crashes (as
it is wont to do; I'm still working on it, and... so is twitter:-), I
need to re-add a gen_event from the irc code to continue getting
notifications.  I think, at least.  This means that the irc code needs
to know when the twitter code has crashed, and when it's back up.
using erlang:monitor buys me a 'DOWN' event, but in that I'm not sure
how to know when the twitter_stream server is up and running again and
ready to receive gen_server:call's.  Either that or the twitter_stream
code should save its state somehow between crashes and go back to its
previous state when it dies.

Sorry if that's all a bit jumbled, but I'm confused myself!

Thank you,
-- 
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/


More information about the erlang-questions mailing list