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?
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With