1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE fileref SYSTEM "fileref.dtd">
<fileref>
<header>
<copyright>
<year>1997</year><year>2018</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</legalnotice>
<title>config</title>
<prepared></prepared>
<docno></docno>
<date></date>
<rev></rev>
</header>
<file>config</file>
<filesummary>Configuration file.</filesummary>
<description>
<p>A <em>configuration file</em> contains values for configuration
parameters for the applications in the system. The <c>erl</c>
command-line argument <seecom marker="erts:erl#config"><c>-config
Name</c></seecom> tells the system to use data in the system configuration
file <c>Name.config</c>.</p>
<p>The erl command-line argument <seecom
marker="erts:erl#configfd"><c>-configfd</c></seecom> works the
same way as the <c>-config</c> option but specifies a file
descriptor to read configuration data from instead of a file.</p>
<p>The configuration data from configuration files and file
descriptors are read in the same order as they are given on the
command line. For example, <c>erl -config a -configfd 3 -config b
-configfd 4</c> would cause the system to read configuration data
in the following order <c>a.config</c>, file descriptor <c>3</c>,
<c>b.config</c>, and file descriptor <c>4</c>. If a configuration
parameter is specified more than once in the given files and file
descriptors, the last one overrides the previous ones.</p>
<p>Configuration parameter values in a configuration file or file
descriptor override the values in the application resource files
(see <seefile marker="app"><c>app(4)</c></seefile>). The values in
the configuration file are always overridden by command-line flags
(see <seecom marker="erts:erl"><c>erts:erl(1)</c></seecom>).</p>
<p>The value of a configuration parameter is retrieved by calling
<c>application:get_env/1,2</c>.</p>
</description>
<section>
<title>File Syntax</title>
<p>The configuration file is to be called <c>Name.config</c>, where
<c>Name</c> is any name.</p>
<p>File <c>.config</c> contains a single Erlang term and
has the following syntax:</p>
<code type="none">
[{Application1, [{Par11, Val11}, ...]},
...
{ApplicationN, [{ParN1, ValN1}, ...]}].</code>
<taglist>
<tag><c>Application = atom()</c></tag>
<item><p>Application name.</p></item>
<tag><c>Par = atom()</c></tag>
<item><p>Name of a configuration parameter.</p></item>
<tag><c>Val = term()</c></tag>
<item><p>Value of a configuration parameter.</p></item>
</taglist>
</section>
<section>
<title>sys.config</title>
<p>When starting Erlang in embedded mode, it is assumed that
exactly one system configuration file is used, named
<c>sys.config</c>. This file is to be located in
<c>$ROOT/releases/Vsn</c>, where <c>$ROOT</c> is the Erlang/OTP
root installation directory and <c>Vsn</c> is the release version.</p>
<p>Release handling relies on this assumption. When installing a
new release version, the new <c>sys.config</c> is read and used
to update the application's configurations.</p>
<p>This means that specifying another <c>.config</c> file, or more
<c>.config</c> files, leads to an inconsistent update of application
configurations. There is, however, a way to point out other config
files from a <c>sys.config</c>. How to do this is described in
the next section.</p>
</section>
<section>
<title>Including Files from sys.config and -configfd Configurations</title>
<p>There is a way to include other configuration files from a
<c>sys.config</c> file and from a configuration that comes
from a file descriptor that has been pointed out with the <seecom
marker="erts:erl#configfd"><c>-configfd</c></seecom> command-line
arguemnt.</p>
<p>The syntax for including files can be described by the
<seeguide marker="system/reference_manual:typespec">Erlang type
language</seeguide> like this:</p>
<code type="none">
[{Application, [{Par, Val}]} | IncludeFile].</code>
<taglist>
<tag><c>IncludeFile = string()</c></tag>
<item>Name of a <c>.config</c> file. The extension
<c>.config</c> can be omitted. It is recommended to use absolute
paths. If a relative path is used in a <c>sys.config</c>,
<c>IncludeFile</c> is searched, first, relative to the
<c>sys.config</c> directory, then relative to the current
working directory of the emulator. If a relative path is used
in a <c>-configfd</c> configuration, <c>IncludeFile</c> is
searched, first, relative to the dictionary containing the
<seefile marker="sasl:script">boot script</seefile> (see also
the <seecom marker="erts:erl#boot"><c>-boot</c></seecom>
command-line argument) for the emulator, then relative to the
current working directory of the emulator. This makes it
possible to use <c>sys.config</c> for pointing out other
<c>.config</c> files in a release or in a node started manually
using <c>-config</c> or <c>-configfd</c> with the same result
whatever the current working directory is.
</item>
</taglist>
<p>When traversing the contents of a <c>sys.config</c> or a
<c>-configfd</c> configuration and a filename is encountered, its
contents are read and merged with the result so far. When an
application configuration tuple <c>{Application, Env}</c> is
found, it is merged with the result so far. Merging means that new
parameters are added and existing parameter values
are overwritten.</p>
<p><em>Example:</em></p>
<code type="none">
sys.config:
["/home/user/myconfig1"
{myapp,[{par1,val1},{par2,val2}]},
"/home/user/myconfig2"].
myconfig1.config:
[{myapp,[{par0,val0},{par1,val0},{par2,val0}]}].
myconfig2.config:
[{myapp,[{par2,val3},{par3,val4}]}].</code>
<p>This yields the following environment for <c>myapp</c>:</p>
<code type="none">
[{par0,val0},{par1,val1},{par2,val3},{par3,val4}]</code>
<p>The run-time system will abort before staring up if an include file
specified in <c>sys.config</c> or a <c>-configfd</c> configuration
does not exist, or is erroneous. However, installing a new release
version will not fail if there is an error while loading an
include file, but an error message is returned and the erroneous
file is ignored.</p>
</section>
<section>
<title>See Also</title>
<p><seefile marker="app"><c>app(4)</c></seefile>,
<seecom marker="erts:erl"><c>erts:erl(1)</c></seecom>,
<seeguide marker="system/design_principles:des_princ">OTP Design Principles</seeguide></p>
</section>
</fileref>
|