In OTP, application denotes a component implementing some specific functionality, that can be started and stopped as a unit, and that can be reused in other systems. This module interacts with application controller, a process started at every Erlang runtime system. This module 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 named
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 is to be located in an application callback module, exporting a predefined set of functions.
For details about applications and behaviours, see
Equivalent to calling
Returns
The function reports
If an error occurs, the applications started by the function are stopped to bring the set of running applications back to its initial state.
Equivalent to
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 configuration parameter
Returns
Works like
Returns the value of the application specification key
Returns
Loads the application specification for an application into the application controller. It also loads the application specifications for any included applications. Notice that the function does not load the Erlang object code.
The application can be specified by its name
The application specification can also be specified directly as a
tuple
If
Example:
Nodes = [cp1@cave, {cp2@cave, cp3@cave}]
This means that the application is preferably to be started
at
If
Returns a list with information about the applications, and included
applications, which are 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 configuration parameter
If
Option
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.
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
Argument
Notice that an application can always be stopped
explicitly by calling
Notice also that the transient type is of little practical use,
because 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 started, to
determine the start type, which is
For a description of
If the process executing the call does not belong to any
application, the function returns
Stops
Last, the application master terminates. Notice that all processes with the application master as group leader, that is, processes spawned from a process belonging to the application, are also terminated.
When stopped, the application is still loaded.
To stop a distributed application,
Takes over the distributed application
Thus, two instances of the application run simultaneously during the takeover, so that data can be transferred from the old to the new instance. If this is not an acceptable behavior, parts of the old instance can be shut down when the new instance is started. However, the application cannot be stopped entirely, at least the top supervisor must remain alive.
For a description of
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-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.
Returns a list with information about the applications that
are currently running.
The following functions are to be exported from an
This function is called whenever an application is started
using
The function is to return
Starts an application with included applications, when synchronization is needed between processes in the different applications during startup.
The start phases are 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.
For a description of
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
are 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 the configuration parameters have changed.