From d92eb79322fa4ee45ce1c0c7c4ed8a573673474b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 16 Jan 2019 15:25:21 +0100 Subject: Add application:set_env/1 and application:set_env/2 It is equivalent to calling application:set_env/4 on each application individually, except it is more efficient. When given duplicate apps or duplicate keys, set_env/1 and set_env/2 will warn. The warning will also be emitted during boot: $ erl -config dupkeys.config -s erlang halt 2019-02-27 11:16:02.653100 application: kernel; duplicate parameter: key1 =WARNING REPORT==== 27-Feb-2019::11:16:02.653100 === application: kernel; duplicate parameter: key1 $ erl -config dupapps.config -s erlang halt 2019-02-27 11:16:02.653100 duplicate application config: kernel =WARNING REPORT==== 27-Feb-2019::11:16:02.653100 === duplicate application config: kernel Prior to this patch, the behaviour was unspecified, and duplicate keys and duplicate apps would behave different depending on the amount of config, the name of the config files, and how those configs would be listed. The goal is to raise an error in the future. --- lib/kernel/doc/src/application.xml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/application.xml b/lib/kernel/doc/src/application.xml index 4e32c1a3a5..5170502581 100644 --- a/lib/kernel/doc/src/application.xml +++ b/lib/kernel/doc/src/application.xml @@ -237,6 +237,41 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}] keys, respectively.

+ + + + Sets the configuration parameters of multiple applications. + +

Sets the configuration Config for multiple + applications. It is equivalent to calling set_env/4 on + each application individially, except it is more efficient. + The given Config is validated before the + configuration is set.

+

set_env/2 uses the standard gen_server time-out + value (5000 ms). Option timeout can be specified + if another time-out value is useful, for example, in situations + where the application controller is heavily loaded.

+

Option persistent can be set to true + to guarantee that parameters set with set_env/2 + are not overridden by those defined in the application resource + file on load. This means that persistent values will stick after the application + is loaded and also on application reload.

+

If an application is given more than once or if an application + has the same key given more than once, the behaviour is undefined + and a warning message will be logged. In future releases, an error + will be raised.

+

set_env/1 is equivalent to set_env(Config, []).

+ +

Use this function only if you know what you are doing, + that is, on your own applications. It is very + application-dependent and + configuration parameter-dependent when and how often + the value is read by the application. Careless use + of this function can put the application in a + weird, inconsistent, and malfunctioning state.

+
+
+
Change the permission for an application to run at a node. -- cgit v1.2.3