50
50
<p>Refer to <seealso marker="doc/design_principles:des_princ">OTP Design Principles</seealso> for more information about
51
51
applications and behaviours.</p>
55
<name name="start_type"/>
58
<name name="restart_type"/>
61
<!-- Parameterized opaque types are NYI: -->
62
<name><marker id="type-tuple_of">tuple_of(T)</marker></name>
63
<desc><p>A tuple where the elements are of type <c>T</c>.</p></desc>
55
<name>get_all_env() -> Env</name>
56
<name>get_all_env(Application) -> Env</name>
68
<name name="get_all_env" arity="0"/>
69
<name name="get_all_env" arity="1"/>
57
70
<fsummary>Get the configuration parameters for an application</fsummary>
59
<v>Application = atom()</v>
60
<v>Env = [{Par,Val}]</v>
61
<v> Par = atom()</v>
62
<v> Val = term()</v>
65
72
<p>Returns the configuration parameters and their values for
66
<c>Application</c>. If the argument is omitted, it defaults to
73
<c><anno>Application</anno></c>. If the argument is omitted, it defaults to
67
74
the application of the calling process.</p>
68
75
<p>If the specified application is not loaded, or if the process
69
76
executing the call does not belong to any application,
74
<name>get_all_key() -> {ok, Keys} | []</name>
75
<name>get_all_key(Application) -> {ok, Keys} | undefined </name>
81
<name name="get_all_key" arity="0"/>
82
<name name="get_all_key" arity="1"/>
76
83
<fsummary>Get the application specification keys</fsummary>
78
<v>Application = atom()</v>
79
<v>Keys = [{Key,Val}]</v>
80
<v> Key = atom()</v>
81
<v> Val = term()</v>
84
85
<p>Returns the application specification keys and their values
85
for <c>Application</c>. If the argument is omitted, it
86
for <c><anno>Application</anno></c>. If the argument is omitted, it
86
87
defaults to the application of the calling process.</p>
87
88
<p>If the specified application is not loaded, the function
88
89
returns <c>undefined</c>. If the process executing the call
94
<name>get_application() -> {ok, Application} | undefined</name>
95
<name>get_application(Pid | Module) -> {ok, Application} | undefined</name>
95
<name name="get_application" arity="0"/>
96
<name name="get_application" arity="1"/>
96
97
<fsummary>Get the name of an application containing a certain process or module</fsummary>
99
<v>Module = atom()</v>
100
<v>Application = atom()</v>
103
99
<p>Returns the name of the application to which the process
104
<c>Pid</c> or the module <c>Module</c> belongs. Providing no
100
<c><anno>Pid</anno></c> or the module <c><anno>Module</anno></c> belongs. Providing no
105
101
argument is the same as calling
106
102
<c>get_application(self())</c>.</p>
107
103
<p>If the specified process does not belong to any application,
113
<name>get_env(Par) -> {ok, Val} | undefined</name>
114
<name>get_env(Application, Par) -> {ok, Val} | undefined</name>
109
<name name="get_env" arity="1"/>
110
<name name="get_env" arity="2"/>
115
111
<fsummary>Get the value of a configuration parameter</fsummary>
117
<v>Application = atom()</v>
122
<p>Returns the value of the configuration parameter <c>Par</c>
123
for <c>Application</c>. If the application argument is
113
<p>Returns the value of the configuration parameter <c><anno>Par</anno></c>
114
for <c><anno>Application</anno></c>. If the application argument is
124
115
omitted, it defaults to the application of the calling
126
117
<p>If the specified application is not loaded, or
133
<name>get_key(Key) -> {ok, Val} | undefined</name>
134
<name>get_key(Application, Key) -> {ok, Val} | undefined</name>
124
<name name="get_key" arity="1"/>
125
<name name="get_key" arity="2"/>
135
126
<fsummary>Get the value of an application specification key</fsummary>
137
<v>Application = atom()</v>
142
128
<p>Returns the value of the application specification key
143
<c>Key</c> for <c>Application</c>. If the application
129
<c><anno>Key</anno></c> for <c><anno>Application</anno></c>. If the application
144
130
argument is omitted, it defaults to the application of
145
131
the calling process.</p>
146
132
<p>If the specified application is not loaded, or
153
<name>load(AppDescr) -> ok | {error, Reason}</name>
154
<name>load(AppDescr, Distributed) -> ok | {error, Reason}</name>
139
<name name="load" arity="1"/>
140
<name name="load" arity="2"/>
155
141
<fsummary>Load an application</fsummary>
157
<v>AppDescr = Application | AppSpec</v>
158
<v> Application = atom()</v>
159
<v> AppSpec = {application,Application,AppSpecKeys}</v>
160
<v> AppSpec = [{Key,Val}]</v>
161
<v> Key = atom()</v>
162
<v> Val = term()</v>
163
<v>Distributed = {Application,Nodes} | {Application,Time,Nodes} | default</v>
164
<v> Nodes = [node() | {node(),..,node()}]</v>
165
<v> Time = integer() > 0</v>
166
<v>Reason = term()</v>
142
<type name="application_spec"/>
143
<type name="application_opt"/>
169
145
<p>Loads the application specification for an application into
170
146
the application controller. It will also load the application
171
147
specifications for any included applications. Note that
172
148
the function does not load the actual Erlang object code.</p>
173
<p>The application can be given by its name <c>Application</c>.
149
<p>The application can be given by its name <c><anno>Application</anno></c>.
174
150
In this case the application controller will search the code
175
path for the application resource file <c>Application.app</c>
151
path for the application resource file <c><anno>Application</anno>.app</c>
176
152
and load the specification it contains.</p>
177
153
<p>The application specification can also be given directly as a
178
tuple <c>AppSpec</c>. This tuple should have the format and
154
tuple <c><anno>AppSpec</anno></c>. This tuple should have the format and
179
155
contents as described in <c>app(4)</c>.</p>
180
<p>If <c>Distributed == {Application,[Time,]Nodes}</c>,
156
<p>If <c><anno>Distributed</anno> == {<anno>Application</anno>,[<anno>Time</anno>,]<anno>Nodes</anno>}</c>,
181
157
the application will be distributed. The argument overrides
182
158
the value for the application in the Kernel configuration
183
parameter <c>distributed</c>. <c>Application</c> must be
159
parameter <c>distributed</c>. <c><anno>Application</anno></c> must be
184
160
the name of the application (same as in the first argument).
185
If a node crashes and <c>Time</c> has been specified, then
186
the application controller will wait for <c>Time</c>
161
If a node crashes and <c><anno>Time</anno></c> has been specified, then
162
the application controller will wait for <c><anno>Time</anno></c>
187
163
milliseconds before attempting to restart the application on
188
another node. If <c>Time</c> is not specified, it will
164
another node. If <c><anno>Time</anno></c> is not specified, it will
189
165
default to 0 and the application will be restarted
191
<p><c>Nodes</c> is a list of node names where the application
167
<p><c><anno>Nodes</anno></c> is a list of node names where the application
192
168
may run, in priority from left to right. Node names can be
193
169
grouped using tuples to indicate that they have the same
194
170
priority. Example:</p>
207
<name>loaded_applications() -> [{Application, Description, Vsn}]</name>
183
<name name="loaded_applications" arity="0"/>
208
184
<fsummary>Get the currently loaded applications</fsummary>
210
<v>Application = atom()</v>
211
<v>Description = string()</v>
212
<v>Vsn = string()</v>
215
186
<p>Returns a list with information about the applications which
216
187
have been loaded using <c>load/1,2</c>, also included
217
applications. <c>Application</c> is the application name.
218
<c>Description</c> and <c>Vsn</c> are the values of its
188
applications. <c><anno>Application</anno></c> is the application name.
189
<c><anno>Description</anno></c> and <c><anno>Vsn</anno></c> are the values of its
219
190
<c>description</c> and <c>vsn</c> application specification
220
191
keys, respectively.</p>
224
<name>permit(Application, Bool) -> ok | {error, Reason}</name>
195
<name name="permit" arity="2"/>
225
196
<fsummary>Change an application's permission to run on a node.</fsummary>
227
<v>Application = atom()</v>
229
<v>Reason = term()</v>
232
<p>Changes the permission for <c>Application</c> to run at
198
<p>Changes the permission for <c><anno>Application</anno></c> to run at
233
199
the current node. The application must have been loaded using
234
200
<c>load/1,2</c> for the function to have effect.</p>
235
201
<p>If the permission of a loaded, but not started, application
261
<name>set_env(Application, Par, Val) -> ok</name>
262
<name>set_env(Application, Par, Val, Timeout) -> ok</name>
227
<name name="set_env" arity="3"/>
228
<name name="set_env" arity="4"/>
263
229
<fsummary>Set the value of a configuration parameter</fsummary>
265
<v>Application = atom()</v>
268
<v>Timeout = int() | infinity</v>
271
<p>Sets the value of the configuration parameter <c>Par</c> for
272
<c>Application</c>.</p>
231
<p>Sets the value of the configuration parameter <c><anno>Par</anno></c> for
232
<c><anno>Application</anno></c>.</p>
273
233
<p><c>set_env/3</c> uses the standard <c>gen_server</c> timeout
274
value (5000 ms). A <c>Timeout</c> argument can be provided
234
value (5000 ms). A <c><anno>Timeout</anno></c> argument can be provided
275
235
if another timeout value is useful, for example, in situations
276
236
where the application controller is heavily loaded.</p>
288
<name>start(Application) -> ok | {error, Reason}</name>
289
<name>start(Application, Type) -> ok | {error, Reason}</name>
248
<name name="start" arity="1"/>
249
<name name="start" arity="2"/>
290
250
<fsummary>Load and start an application</fsummary>
292
<v>Application = atom()</v>
293
<v>Type = permanent | transient | temporary</v>
294
<v>Reason = term()</v>
297
<p>Starts <c>Application</c>. If it is not loaded,
252
<p>Starts <c><anno>Application</anno></c>. If it is not loaded,
298
253
the application controller will first load it using
299
254
<c>load/1</c>. It will make sure any included applications
300
255
are loaded, but will not start them. That is assumed to be
301
taken care of in the code for <c>Application</c>.</p>
256
taken care of in the code for <c><anno>Application</anno></c>.</p>
302
257
<p>The application controller checks the value of
303
258
the application specification key <c>applications</c>, to
304
259
ensure that all applications that should be started before
334
<name>start_type() -> StartType | local | undefined</name>
289
<name name="start_type" arity="0"/>
335
290
<fsummary>Get the start type of an ongoing application startup.</fsummary>
337
<v>StartType = normal | {takeover,Node} | {failover,Node}</v>
338
<v> Node = node()</v>
341
292
<p>This function is intended to be called by a process belonging
342
293
to an application, when the application is being started, to
343
determine the start type which is either <c>StartType</c> or
294
determine the start type which is either <c><anno>StartType</anno></c> or
344
295
<c>local</c>.</p>
345
<p>See <c>Module:start/2</c> for a description of
346
<c>StartType</c>.</p>
296
<p>See <seealso marker="#start_type"><c>Module:start/2</c></seealso> for a description of
297
<c><anno>StartType</anno></c>.</p>
347
298
<p><c>local</c> is returned if only parts of the application is
348
299
being restarted (by a supervisor), or if the function is
349
300
called outside a startup.</p>
355
<name>stop(Application) -> ok | {error, Reason}</name>
306
<name name="stop" arity="1"/>
356
307
<fsummary>Stop an application</fsummary>
358
<v>Application = atom()</v>
359
<v>Reason = term()</v>
362
<p>Stops <c>Application</c>. The application master calls
309
<p>Stops <c><anno>Application</anno></c>. The application master calls
363
310
<c>Module:prep_stop/1</c>, if such a function is defined, and
364
311
then tells the top supervisor of the application to shutdown
365
312
(see <c>supervisor(3)</c>). This means that the entire
387
<name>takeover(Application, Type) -> ok | {error, Reason}</name>
334
<name name="takeover" arity="2"/>
388
335
<fsummary>Take over a distributed application</fsummary>
390
<v>Application = atom()</v>
391
<v>Type = permanent | transient | temporary</v>
392
<v>Reason = term()</v>
395
337
<p>Performs a takeover of the distributed application
396
<c>Application</c>, which executes at another node
338
<c><anno>Application</anno></c>, which executes at another node
397
339
<c>Node</c>. At the current node, the application is
398
340
restarted by calling
399
341
<c>Module:start({takeover,Node},StartArgs)</c>. <c>Module</c>
416
<name>unload(Application) -> ok | {error, Reason}</name>
358
<name name="unload" arity="1"/>
417
359
<fsummary>Unload an application</fsummary>
419
<v>Application = atom()</v>
420
<v>Reason = term()</v>
423
<p>Unloads the application specification for <c>Application</c>
361
<p>Unloads the application specification for <c><anno>Application</anno></c>
424
362
from the application controller. It will also unload
425
363
the application specifications for any included applications.
426
364
Note that the function does not purge the actual Erlang
431
<name>unset_env(Application, Par) -> ok</name>
432
<name>unset_env(Application, Par, Timeout) -> ok</name>
369
<name name="unset_env" arity="2"/>
370
<name name="unset_env" arity="3"/>
433
371
<fsummary>Unset the value of a configuration parameter</fsummary>
435
<v>Application = atom()</v>
437
<v>Timeout = int() | infinity</v>
440
<p>Removes the configuration parameter <c>Par</c> and its value
441
for <c>Application</c>.</p>
373
<p>Removes the configuration parameter <c><anno>Par</anno></c> and its value
374
for <c><anno>Application</anno></c>.</p>
442
375
<p><c>unset_env/2</c> uses the standard <c>gen_server</c>
443
timeout value (5000 ms). A <c>Timeout</c> argument can be
376
timeout value (5000 ms). A <c><anno>Timeout</anno></c> argument can be
444
377
provided if another timeout value is useful, for example, in
445
378
situations where the application controller is heavily loaded.</p>
457
<name>which_applications() -> [{Application, Description, Vsn}]</name>
458
<name>which_applications(Timeout) -> [{Application, Description, Vsn}]</name>
390
<name name="which_applications" arity="0"/>
391
<name name="which_applications" arity="1"/>
459
392
<fsummary>Get the currently running applications</fsummary>
461
<v>Application = atom()</v>
462
<v>Description = string()</v>
463
<v>Vsn = string()</v>
464
<v>Timeout = int() | infinity</v>
467
394
<p>Returns a list with information about the applications which
468
are currently running. <c>Application</c> is the application
469
name. <c>Description</c> and <c>Vsn</c> are the values of its
395
are currently running. <c><anno>Application</anno></c> is the application
396
name. <c><anno>Description</anno></c> and <c><anno>Vsn</anno></c> are the values of its
470
397
<c>description</c> and <c>vsn</c> application specification
471
398
keys, respectively.</p>
472
399
<p><c>which_applications/0</c> uses the standard
473
<c>gen_server</c> timeout value (5000 ms). A <c>Timeout</c>
400
<c>gen_server</c> timeout value (5000 ms). A <c><anno>Timeout</anno></c>
474
401
argument can be provided if another timeout value is useful,
475
402
for example, in situations where the application controller
476
403
is heavily loaded.</p>