1 %%% Copyright (c) 2007- Facebook
2 %%% Distributed under the Thrift Software License
4 %%% See accompanying file LICENSE or visit the Thrift site at:
5 %%% http://developers.facebook.com/thrift/
9 -export([start
/0, stop
/0, config
/1, config
/2, reconfig
/1]).
11 -include("thrift.hrl").
14 %%% behavior definition
18 application:start(thrift
).
21 application:stop(thrift
).
28 config(?MODULE
, Item
).
31 case application:get_env(App
, Item
) of
35 ?
ERROR("configuration for ~p is unavailable", [Item
]),
37 exit({missing_config
, App
, Item
})
41 BFName
= filename:basename(Config
, ".config"),
42 FName
= filename:join(filename:dirname(Config
),
45 case file:consult(FName
) of
47 {error
, file_error
, file:format_error(R
)};
49 {error
, file_error
, Posix
};
50 {ok
, [List
]} when is_list(List
) ->
56 reconfig1([{App
, List
}|Tl
]) ->
57 reconfig2(List
, App
, 0),
60 reconfig2([], App
, Count
) ->
61 ?
INFO("application ~p reconfigured: ~p keys updated", [App
, Count
]),
63 reconfig2([{Par
, Val
}|Tl
], App
, Count
) ->
64 application:set_env(App
, Par
, Val
),
65 reconfig2(Tl
, App
, Count
+1).