How to configure processes, (and applications)

Sean Hinde sean.hinde@REDACTED
Tue Feb 22 11:22:08 CET 2005

On 21 Feb 2005, at 16:11, Anders Nygren wrote:

> Sorry,
> but it got sent before I was finished.
> Hi
> I am pondering the question of how to best get configuration data
> to processes and/or applications in an OTP based system.
> So far I have as a precondition that
> 1 - Useful default values are in the application resource file
> 2 - Installation specific values are in the sys.config file
> But my question is, "How do I best get the data into the processes
> that need it?"

Most of our apps use a simple mechanism where the supervisor reads the 
config and passes it into the start_link function. It works well.

We have moved away from using sys.config for our own apps (i.e. stuff 
where we can influence this - not inets, kernel and friends) and now 
have a well known config directory location which holds a file called 
app_name.conf for any application which needs config data. This is 
normally something which can be read with file:consult/1.

This allows us to have a single standard sys.config for all new systems 
which makes multiple configs easier to manage, and crucially a restart 
is not needed to re-read the config.

Changing config on the fly is done by exporting config change functions 
for each gen_server and putting code to handle this in the call 
callbacks. We also have a persistent storage for config data modelled 
along the same api as application:get_env etc. Applications are free to 
use that instead of or as well as config files.

I'm a big fan of K.I.S.S!


More information about the erlang-questions mailing list