[erlang-questions] supervisors & slow init's

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed Dec 4 20:09:13 CET 2013


Fire up the supervisor tree as fast as possible, then do the connectivity.
A good example is how mnesia does it. You have to call
mnesia:wait_for_tables/1,2 in order to wait for tables to come online, but
the bootup of mnesia itself is very fast. So in your case, you would call:
hardware:wait_ready(arduino, 8000) to wait at most 8000ms for the arduino
to come online and so on.

There is a recent post by Fred Hebert on this subject,

http://ferd.ca/it-s-about-the-guarantees.html

you might want to read as well.


On Wed, Dec 4, 2013 at 6:35 PM, David Welton <davidnwelton@REDACTED> wrote:

> > I need to start up something, hardware, say, that takes a while to
> > initialize, via an external process.  The next child of my supervisor
> > should not start until the first, slow one does.   How should I go
> > about notifying Erlang that things are done?  Currently, the external
> > system connects as an external node and sends a message.  Can I have a
> > receive in the gen_server's init to wait for that?
>
> Initial tests show that it does work, both with a pid, and with the
> name of the server.
>
> Whether it's the best thing to do or not is not something I'm sure of.
>  If I have a 'ready' callback that receives a message from the
> hardware driver, how do I only then start up the other gen_servers
> under the supervisor - just do it dynamically?  Seems a bit roundabout
> compared to just starting everything in the right order.
>
> --
> David N. Welton
>
> http://www.welton.it/davidw/
>
> http://www.dedasys.com/
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131204/294dc8fc/attachment.htm>


More information about the erlang-questions mailing list