In OTP, application denotes a component implementing some specific functionality, that can be started and stopped as a unit, and which can be re-used in other systems as well. This module interfaces the application controller, a process started at every Erlang runtime system, and contains functions for controlling applications (for example starting and stopping applications), and functions to access information about applications (for example configuration parameters).
An application is defined by an application specification. The specification is normally located in an
application resource file called
This module can also be viewed as a behaviour for an application implemented according to the OTP design principles as a supervision tree. The definition of how to start and stop the tree should be located in an application callback module exporting a pre-defined set of functions.
Refer to
A tuple where the elements are of type
Returns the configuration parameters and their values for
If the specified application is not loaded, or if the process
executing the call does not belong to any application,
the function returns
Returns the application specification keys and their values
for
If the specified application is not loaded, the function
returns
Returns the name of the application to which the process
If the specified process does not belong to any application,
or if the specified process or module does not exist,
the function returns
Returns the value of the configuration parameter
If the specified application is not loaded, or
the configuration parameter does not exist, or if the process
executing the call does not belong to any application,
the function returns
Returns the value of the application specification key
If the specified application is not loaded, or
the specification key does not exist, or if the process
executing the call does not belong to any application,
the function returns
Loads the application specification for an application into the application controller. It will also load the application specifications for any included applications. Note that the function does not load the actual Erlang object code.
The application can be given by its name
The application specification can also be given directly as a
tuple
If
Nodes = [cp1@cave, {cp2@cave, cp3@cave}]
This means that the application should preferably be started
at
If
Returns a list with information about the applications which
have been loaded using
Changes the permission for
If the permission of a loaded, but not started, application
is set to
If the permission of a running application is set to
If the application is distributed, setting the permission to
The function does not return until the application is
started, stopped or successfully moved to another node.
However, in some cases where permission is set to
By default, all applications are loaded with permission
Sets the value of the configuration parameter
Use this function only if you know what you are doing, that is, on your own applications. It is very application and configuration parameter dependent when and how often the value is read by the application, and careless use of this function may put the application in a weird, inconsistent, and malfunctioning state.
Starts
The application controller checks the value of
the application specification key
The application controller then creates an application master for the application. The application master is
the group leader of all the processes in the application.
The application master starts the application by calling
the application callback function
The
Note that it is always possible to stop an application
explicitly by calling
Note also that the transient type is of little practical use,
since when a supervision tree terminates, the reason is set to
This function is intended to be called by a process belonging
to an application, when the application is being started, to
determine the start type which is either
See
If the process executing the call does not belong to any
application, the function returns
Stops
Last, the application master itself terminates. Note that all processes with the application master as group leader, i.e. processes spawned from a process belonging to the application, thus are terminated as well.
When stopped, the application is still loaded.
In order to stop a distributed application,
Performs a takeover of the distributed application
Thus two instances of the application will run simultaneously during the takeover, which makes it possible to transfer data from the old to the new instance. If this is not acceptable behavior, parts of the old instance may be shut down when the new instance is started. Note that the application may not be stopped entirely however, at least the top supervisor must remain alive.
See
Unloads the application specification for
Removes the configuration parameter
Use this function only if you know what you are doing, that is, on your own applications. It is very application and configuration parameter dependent when and how often the value is read by the application, and careless use of this function may put the application in a weird, inconsistent, and malfunctioning state.
Returns a list with information about the applications which
are currently running.
The following functions should be exported from an
This function is called whenever an application is started
using
The function should return
This function is used to start an application with included applications, when there is a need for synchronization between processes in the different applications during startup.
The start phases is defined by the application specification
key
The function is called for each start phase (as defined for the primary application) for the primary application and all included applications, for which the start phase is defined.
See
This function is called when an application is about to be stopped, before shutting down the processes of the application.
The function is optional. If it is not defined, the processes
will be terminated and then
This function is called whenever an application has stopped.
It is intended to be the opposite of
This function is called by an application after a code replacement, if there are any changes to the configuration parameters.