在erlang的项目中必定会有一个`.app`文件,该文件除了指定项目入口(必须是application behaviour)之外,还包含很多信息。
{application, Application,
[{description, Description},
{id, Id},
{vsn, Vsn},
{modules, Modules},
{maxP, MaxP},
{maxT, MaxT},
{registered, Names},
{included_applications, Apps},
{applications, Apps},
{env, Env},
{mod, Start},
{start_phases, Phases},
{runtime_dependencies, RTDeps}]}.
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] []
Module = Name = App = Par = Phase = atom()
Val = StartArgs = PhaseArgs = term()
ApplicationVersion = string()
Application:项目名
对application 控制器而言,所有的键都是可选的,对于任何省略的都有对应的默认值。
systools需要更多的信息,所以下列的键是强制性的:
- description
- vsn
- modules
- registered
- applications
description:项目描述
id:标识
vsn:版本标识
modules:程序引用的模块,systools在生成启动脚本和tar文件时会用到。一个模块只能被一个application定义。
maxP:弃用
maxT:允许程序运行的最大时间,在指定的时间后,程序会自动终止。
registered:被application注册的名称,systools使用这个列表来检测冲突。
included_applications:当前application包含的其他application列表,当启动时会将列表的application加载进来,当不启动。等同于列表的application顶层监控器是由当前程序的监控器启动的。
applications:当前application启动前需要启动的所有applications,systools使用这个来生成正确的启动脚本。默认为空,但是要注意,所有的application都依赖Kernel和STDLIB。
env:配置参数,可通过application:get_env/1,2来获取值,这里设置的值可被配置文件(Erlang -- config)或者命令行标志(Erlang -- erl)覆盖.
mod:指定回调的模块和参数,详见Erlang -- application
start_phases:启动阶段的参数列表,如果有设置的话,启动时除了调用Module:start/2外,还会调用Module:start_phase(Phase,Type,PhaseArgs),只有在这个扩展的启动过程后,application:start(Application)才有返回。
runtime_dependencies:依赖的applications版本列表,例如"kernel-3.0"。所用的依赖项版本需要高于或等于指定版本,有关如何比较应用程序版本的信息,请参阅系统原理用户指南中的部分版本(Erlang -- Versions)。