[erlang-questions] get_env returns a surprise...

Ulf Wiger ulf@REDACTED
Sun Jan 22 10:49:04 CET 2012

It's a feature. :)

See the following in application_controller:load/2:

    NewEnv2 = merge_app_env(NewEnv, CmdLineEnv),
    NewEnv3 = keyreplaceadd(included_applications, 1, NewEnv2,
                            {included_applications, IncApps}),

If I rack my brain, I seem to recall that included applications were added
on request from the AXD 301 project. We had so much code, and so many
development teams, that we needed a way to automatically integrate the
work from several teams into one "top application" (i.e. an instance that 
could move as one unit during failver and takeover).

The prototype was something I wrote, using some Ericsson vernacular
and integrating "load module files", .appLm files, into a bigger .app file.
During discussions with OTP, we agreed that it could be done in runtime
with an 'included_applications' attribute, as long as we could inspect
the attribute dynamically. We already had a number of standardized
env variables ('$go' and '$takeover' function hooks etc) that were picked
up and used by some central coordination functions.

However, at the time, application:get_key/2 didn't yet exist, so the quick
way to make the 'included_applications' attribute available for inspection
was to get to it via application:get_env/2.

Of course, there is no reason to keep it around anymore, and I don't think
it's even documented anywhere.

Ulf W

On 21 Jan 2012, at 23:02, Steve Davis wrote:

> Bug or feature? Why does the key included_applications appear twice,
> i.e. also under env which it is specifically not a part of?
> 6> application:get_all_key(myapp).
> {ok,[{description,"My App"},
>     {id,[]},
>     {vsn,"1.0.0"},
>     {modules,[]},
>     {maxP,infinity},
>     {maxT,infinity},
>     {registered,[]},
>     {included_applications,[public_key,ssl]},
>     {applications,[kernel,stdlib]},
>     {env,[{included_applications,[public_key,
>                                   ssl]}]},
>     {mod,{ice_app,[]}},
>     {start_phases,undefined}]}
> best,
> /s
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list