The application resource file specifies the resources an application uses, and how the application is started. There must always be one application resource file for each application in the system.
This file is read when an application is loaded, or by the
start script generating tools (systools
).
The application resource file is called
Name.app
where Name
is the name of the
application. The file should be located in the ebin
directory for the application.
The .app
file contains one single Erlang term, which is
called an application specification. The file has the
following syntax:
{application, ApplName, [{description, String}, {vsn, String}, {id, String}, {modules, [{Mod1,Vsn1}, Mod2, {Mod3,Vsn3} .., {ModN,VsnN}]}, {maxP, Int | infinity}, {maxT, Seconds | infinity}, {registered, [Name1, Name2, ...]}, {applications, [Appl1, Appl2, .., ApplN]}, {included_applications, [Appl1, Appl2, .., ApplN]}, {env, [{Par1, Val1}, {Par2, Val2} .., {ParN, ValN}]}, {mod, {Mod, StartArgs}}, {start_phases, [{Phase, PhaseArgs}]}]}.
The keys have the following meanings:
Name = atom()
is the name of the application.
Description = string()
is a textual description
of the application.
Vsn = string()
is the version of the
application. This string must be a valid filename.
Id = string()
is the product identification of the application.
Modules = [Mod1 | {Mod1, Vsn1}]
is a list
of all the modules and their versions introduced by this
application. A module can be listed without version, only the
name of the module is stated. A module can only be defined in
one application.
MaxT = int() | infinity
is the maximum time that
the application can run (or the atom infinity
). The key
maxT
is optional and defaults to infinity
.
Registered = [atom()]
is a list of all the names
of registered processes started in this application.
applications = [atom()]
is a list of
applications which must be started before this application is
started. Most applications have dependencies to the
Kernel and STDLIB applications.
included_applications = [atom()]
is a list of
applications which are included by this application. An
included application is loaded, but not started, by the
application_controller
. Processes implemented in an
included application should be placed underneath a supervisor
in the including application. This key is optional and
defaults to []
.
env
is a list of the environment variables in
the application. Each parameter ParX
is an atom, and
the associated ValX
can be any term. The env
key is optional and defaults to an empty list.
mod
is the application callback module of the
application behaviour. The application master starts the
application by evaluating the function Mod:start(Type,
StartArgs)
. When the application has stopped, by command
or because it terminates, the application master calls
Mod:stop(State)
to let the application clean up. If no
State
was returned from Mod:start/2
,
Mod:stop([])
is called.
mod
key should be omitted for applications which
are code libraries, such as the application STDLIB.
These applications have no dynamic behaviour of their own
and should not have a start function.
start_phases
is a list of start phases and the attached start arguments
for the application. The application master starts the
application by evaluating the function Mod:start_phase(Phase, Type,
PhaseArgs)
for each defined start phase.
Mod
is the same callback module as defined in the mod
key.
Each parameter Phase
is an atom, and the
associated PhaseArgs
is a list of any terms.
The key start_phases
is optional, and the behaviour of the system is
dependent if the key is defined or not, refer to application (3).
application(3), systools(3)