app(4)
app(4) π β Erlang Module Definition
okay so bestie, welcome to app(4), the Erlang Module Definition for the application resource file. It's literally the blueprint for which resources an application uses and how it gets started. Main-character energy only. β¨
πΈ NAME πΈ
app β Application resource file. Short, iconic, done. π
π¦ DESCRIPTION π¦
The application resource file is the receipts for the resources an application uses and how the application is started. There must always be one application resource file called Application.app for each application Application in the system. That's non-negotiable, bestie.
The application controller reads this file when an application is loaded/started. The functions in systools also use it, for example when generating start scripts. Obsessed with a file that does both. π
π File Syntax π
The file is to be called Application.app, where Application is the application name. It is to be located in directory ebin for the application.
The file must contain a single Erlang term, which is called an application specification:
{application, Application,
[{description, Description},
{id, Id},
{vsn, Vsn},
{modules, Modules},
{maxP, MaxP},
{maxT, MaxT},
{registered, Names},
{included_applications, Apps},
{optional_applications, Apps},
{applications, Apps},
{env, Env},
{mod, Start},
{start_phases, Phases},
{runtime_dependencies, RTDeps}]}.
Here's the value/default menu β every row is important, no skipping:
Value Default
----- -------
Application atom() -
Description string() ""
Id string() ""
Vsn string() ""
Modules [Module] []
MaxP int() infinity
MaxT int() infinity
Names [Name] []
Apps [App] []
Env [{Par,Val}] []
Start {Module,StartArgs} []
Phases [{Phase,PhaseArgs}] undefined
RTDeps [ApplicationVersion] []
And the type definitions, because we keep it precise:
Module = Name = App = Par = Phase = atom()
Val = StartArgs = PhaseArgs = term()
ApplicationVersion = string()
Applicationβ Application name. π
For the application controller, all keys are optional. The respective default values are used for any omitted keys. Chill.
The functions in systools require more information. If they are used, the following keys are mandatory:
descriptionvsnmodulesregisteredapplications
The other keys are ignored by systools. That's the rule, bestie. π
descriptionβ A one-line description of the application. One line. Don't write a novel. πidβ Product identification, or similar. You know, the ID vibe. πͺͺvsnβ Version of the application. The version. Thevsn. Slay. βmodulesβ Every module this application introduces.systoolsuses this list when generating start scripts and tar files. A module can only be defined in one application. No module double-booking, periodt. π«maxPβ π¨ Deprecated - is ignored. Maximum number of processes allowed in the application. It's still in the manual, but it's ignored, so don't build your whole personality around it. πmaxTβ Maximum time, in milliseconds, that the application is allowed to run. After the specified time, the application terminates automatically. So yes, it will shut itself down. β°registeredβ All names of registered processes started in this application.systoolsuses this list to detect name clashes between different applications. Name-clash detection is lowkey iconic. πincluded_applicationsβ All applications included by this application. When this application is started, all included applications are loaded automatically, but not started, by the application controller. It is assumed that the top-most supervisor of the included application is started by a supervisor of this application. Loaded, not started β say it with me. πapplicationsβ All applications that must be started before this application. If an application is also listed inoptional_applications, then the application is not required to exist (but if it exists, it is also guaranteed to be started before this one).systoolsuses this list to generate correct start scripts. Defaults to the empty list, but notice that all applications have dependencies to (at least) Kernel and STDLIB. Kernel and STDLIB are always in the group chat. π«Άoptional_applicationsβ A list of applications that are optional. Note: if you want an optional dependency to be automatically started before the current application whenever it is available, it must be listed on bothapplicationsandoptional_applications. Both. Lists. Bestie. β¨envβ Configuration parameters used by the application. The value of a configuration parameter is retrieved by callingapplication:get_env/1,2. The values in the application resource file can be overridden by values in a configuration file (seeconfig(4)) or by command-line flags (seeerts:erl(1)). Overridable, documented, and cute. πmodβ Specifies the application callback module and a start argument, seeapplication. Keymodis necessary for an application implemented as a supervision tree, otherwise the application controller does not know how to start it.modcan be omitted for applications without processes, typically code libraries, for example, STDLIB. Supervision tree? You needmod. Code library with no processes? You can leave it out. π§start_phasesβ A list of start phases and corresponding start arguments for the application. If this key is present, the application master, in addition to the usual call toModule:start/2, also callsModule:start_phase(Phase,Type,PhaseArgs)for each start phase defined by keystart_phases. Only after this extended start procedure,application:start(Application)returns. So the start call is not done until the phases are done. π
Start phases can be used to synchronize startup of an application and its included applications. In this case, key mod must be specified as follows:
{mod, {application_starter,[Module,StartArgs]}}
The application master then calls Module:start/2 for the primary application, followed by calls to Module:start_phase/3 for each start phase (as defined for the primary application), both for the primary application and for each of its included applications, for which the start phase is defined.
This implies that for an included application, the set of start phases must be a subset of the set of phases defined for the primary application. For more information, see Applications in OTP Design Principles. Subset, not superset β write that down. π«‘
runtime_dependenciesβ A list of application versions that the application depends on. An example of such an application version is"kernel-3.0". Application versions specified as runtime dependencies are minimum requirements. That is, a larger application version than the one specified in the dependency satisfies the requirement. For information about how to compare application versions, see section Versions in the System Principles User's Guide. Minimum requirement means a bigger version can still satisfy it. β
Notice that the application version specifies a source code version. One more, indirect, requirement is that the installed binary application of the specified version is built so that it is compatible with the rest of the system. So it's not just the source version β the installed binary has to be compatible with the rest of the system too. π§
Some dependencies can only be required in specific runtime scenarios. When such optional dependencies exist, these are specified and documented in the corresponding "App" documentation of the specific application. Optional dependency lore lives in that app's own docs. π
π See Also π
applicationsystools
Cute sign-off, bestie: source is Ericsson AB, version is kernel 11.0.4, and the manual page is app(4). The footer doesn't print a date, so I'm not inventing one β that's the whole footer tea. π
β¨
π¦ where this page comes from
- arch rolling: erlang-core 29.1.1-1 Β· Apache-2.0
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms