starting application after a set_env variable
Roberto Ostinelli
roberto@REDACTED
Sat Jun 20 11:23:26 CEST 2009
dear all,
i'm starting an application which i need to dinamically configure.
therefore, in the my_app.app file, i set an empty list as env:
{application, my_app,
[
{description, "My App"},
{vsn, "0.3"},
[...]
{env, []},
{mod, {my_app, []}}
]}.
then, before starting the application, i set the env variables i need,
with:
application:set_env(my_app, var1, "value").
then i start the application with application:start(my_app), and in
the start/2 function of my_app i have:
start(_Type, _StartArgs) ->
{ok, Var1} = application:get_env(my_app, var1),
my_sup:start_link(Var1).
so, basically i use Var1 as parameter of my_sup, which is my top level
supervisor.
i can see that Var1 is correct within my_app:start/2, because if i
print it out it corresponds to the string "value".
however, the application fails to start, and i get the following:
{error,{shutdown,{my_app,start,[normal,[]]}}}
=INFO REPORT==== 20-Jun-2009::11:12:35 ===
application: my_app
exited: {shutdown,{my_app,start,[normal,[]]}}
type: temporary
if, instead, i set the var1 in the my_app.app file, without changing
ANYTHING in the code, everything works correctly:
{application, my_app,
[
{description, "My App"},
{vsn, "0.3"},
[...]
{env, [{var1, "value"}]},
{mod, {my_app, []}}
]}.
is there some kind soul to tell me what i'm doing wrong?
thank you in advance,
r.
More information about the erlang-questions
mailing list