Application parameter configuration of Erlang/OTP

Source: Internet
Author: User

Reprinted: http://cryolite.iteye.com/blog/1663436

Erlang/OTP organizes a group of modules that complete specific functions, called applications. This is not a good name. It has different meanings from the conventional application. For example, in the development of Jee, the entire application system is called an application; in iOS, an independent game and a small tool are called an application.

The Application of Erlang/OTP is the most basic behavior, which is the form of Erlang code and function organization (see Erlang
OTP Design Principles)

We can set various parameters for the application to adjust the runtime behavior. For example, the lager application has multiple log levels (debug/INFO/warning/error ), setting different levels of logs will affect log output. In addition, the log file name/storage location can be configured. These can be configured as runtime parameters of the lager when it is started.

Application parameters can be configured in many places (including the configuration file and Erlang running parameters), so we can find out the configuration relationship between these different places (such as the default configuration location and how to override the override parameter) is the Basic Skill for Erlang OTP development.

The running parameters of the application can be viewed as an environment variable and can be configured at three levels,


The upper-layer configuration can overwrite the lower-layer Configuration:

The bottom layer (orange). Each application requires its own resource file (. APP files). These files are all in a unified format, with an env attribute. Configure environment parameters for the application. Because the parameters of the underlying configuration can always be overwritten by parameters in the upper layer, and the parameters in the resource file are limited to the current application, the default parameters of the application are best configured here.

The second layer (green). When multiple applications are packaged and released together with the Erlang Runtime (including the Lib Library), the entire release package (red dotted box) will have a sys. config, in SYS. all applications can be configured in the config file. parameters with the same name will be overwritten. This file can configure parameters for multiple applications at the same time. Not all are called SYS. config. You can specify other names in Option-config of the Erl command.

The highest layer (blue) directly configures parameters for an application in the Erl command. For example, if you want to debug the lager Log Level:

Bash code
  1. Erl-Lager handlers '[{lager_console_backend, debug}]'


Obviously, the parameter value can be a complex Erlang term. Remember to use quotation marks.

This level is obviously suitable for temporary parameter modification during application development and debugging.


In addition, the configuration parameters take effect before the application is started.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.