[erlang-questions] Included applications

Dennis Novikov dennis.novikov@REDACTED
Tue Jan 12 00:38:43 CET 2010


On Tue, Jan 12, 2010 at 12:46 AM, Max E. Kuznecov <mek@REDACTED> wrote:
> Hello!
> I've got a question about included_application option in app file.
> What I want is to start my system by running single top-level
> supervisor and let it start all other required applications under its
> supervision tree.
> manpage for app(4) says:
> included_applications:
>             All applications which are included by this application.
> When  this  application  is  started,  all
>             included  application will automatically be loaded, but
> not started, by the application controller.
>             It is assumed that the topmost supervisor of the included
> application is started by a supervisor of
>             this application.
> I cannot get it how should I actually start those included applications.
> If I write in toplevel.app:
> {included_applications, [worker1, worker2]},
> And in toplevel_sup.erl:
> {ok, Included} = application:get_key(included_applications),
> lists:foreach(fun(App) ->  application:start(App) end, Included),
> I end up with both worker1 and worker2  indeed started. But appmon
> shows they're both in the same level as my toplevel, i.e. they're not
> in topelevel's supervision tree (or appmon just doesn't show that
> relation?)
> If I instead replace application:start() with App:start_link(), I get
> supervision tree I was expecting for (both workers under toplevel's
> tree), but calling application:which_applications() shows only
> toplevel as being loaded and started.
> I'm quite confused about all this. Could anyone please explain what is
> the proper way of achieving my goal here?

That's quite logical, as each of your App:start_link() probably starts
main supervisor of a corresponding included application.

Included application is a part of main one. Try this in included application:
In first case it will return {ok, included_app1}
while in second case it will return {ok, toplevel}

Later variant is how included application supposed to be started.

  Dennis Novikov

More information about the erlang-questions mailing list