Loading application variables

Serge <>
Wed Jun 21 14:09:35 CEST 2006

Actually, there is a way to reload the application configuration from 
sys.config without restarting a node using a non-documented 
application_controller's call (in a similar way how it's done by the 
release handler):

reload_config(AppNames, ConfigFile) ->
     {ok, [Config]} = file:consult(ConfigFile),
     Apps = [{application, A, element(2,application:get_all_key(A))}
             || {A,_,_} <- application:while_applications()],

It would be nice if the following function was exported from the 


then, you wouldn't need to pass the ConfigFile name to the 
reload_config/2 written above, but do:

Config = application_controller:check_conf().



Pupeno wrote:
> On Sun, 2006-06-11 at 13:39 +0100, Sean Hinde wrote:
>>On 11 Jun 2006, at 13:06, Pupeno wrote:
>>>On Sun, 2006-06-11 at 14:02 +0200, Ulf Wiger wrote:
>>>>I don't know if there's a standard function for loading  
>>>>the .config file,
>>>>but you can read and parse a .config file with
>>>>file:consult("miselfu.config"), and you can set environment  
>>>>variables with
>>>>application:set_env(AppName, Key, Value).
>>>So, you don't normally work that way ? Opening up a shell on Emacs,
>>>running the application and re-loading code as it is modified ?
>>I would think that most more serious erlang applications use the  
>>sys.config file for a few parameters that are only required at  
>>startup and not subject to change. Parameters that should change at  
>>runtime would typically be stored in a database or opened up as APIs  
>>so they can be changed without restarting the application.
>>Of course your application might be such that it can be restarted  
>>after every config change, in which case sys.config might be sufficient.
> So far, these configurations, are port numbers. You have to interrupt
> the service anyway to change the port you offer the service on. Although
> I may store them on a DB latter, right now I only want to be able to run
> the app from erl.

More information about the erlang-questions mailing list