Loading application variables

Ulf Wiger ulf@REDACTED
Sun Jun 11 19:20:32 CEST 2006


Den 2006-06-11 16:42:55 skrev Pupeno <pupeno@REDACTED>:

>> The module proplists is a convenient way to handle
>> {Key, Value} options. You can, for example, do:
>>
>> start(StartOpts) ->
>>    Options = StartOpts ++ application:get_all_env(?APP_NAME),
>>    Port = proplists:get_value(port, Options),
>>    ...
>>
>>
>> The proplists module will fetch the first instance of a given
>> key, so all you need to do to override the defaults is to
>> prepend the new values to the list.
>
> Does this mean that I would not be using the standard way of application
> to load configuration files ?

No, you would use applications and config files in the normal fashion. You  
just don't look up the environment parameters using application:get_env()  
at runtime, but rather in bulk at application start, copying the values to  
your own dynamic store (e.g. a mnesia ram copy table). This gives you the  
freedom to tweak the environment at will.

BR,
Ulf W
-- 
Ulf Wiger



More information about the erlang-questions mailing list