Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang store initial application configuration

Tags:

erlang

I am working on a monitoring app and I have to pass in at startup some initial configuration which consists of a couple of lists of IP addresses. What's the OTP way to pass this data to the application - through the .app file or is there any other general accepted way?

like image 329
hyperboreean Avatar asked Jul 19 '11 14:07

hyperboreean


2 Answers

Use an Erlang configuration file:

A configuration file contains values for configuration parameters for the applications in the system. The erl command line argument -config Name tells the system to use data in the system configuration file Name.config.

Configuration parameter values in the configuration file will override the values in the application resource files (see app(4)). The values in the configuration file can be overridden by command line flags (see erl(1)).

The value of a configuration parameter is retrieved by calling application:get_env/1,2.

If you need to override them at runtime, you can use application:set_env/3, but with care.

like image 79
Roberto Aloi Avatar answered Oct 04 '22 17:10

Roberto Aloi


you can handle configuration in several ways. here a link to another stackoverflow topic

IMHO i suggest .app file, or you can use a configuration file (here another link to stackoverflow topic)

like image 36
user601836 Avatar answered Oct 04 '22 17:10

user601836