Where should you put application properties in a rebar erlang application?

倖福魔咒の 提交于 2019-12-12 11:23:42

问题


A newbie question: I wrote my first rebar based erlang application. I want to configure some basic properites like server host etc. Where is the best place to put them and how should I load them into the app?


回答1:


The next steps are to make a release and create a node in it. A node runs your application in a standalone Erlang VM. A good starting point for creating a release using rebar:

Erlang Application Management with Rebar

Once you have created a release. The configuration properties for all applications in your node can then be added to

{your-app}/{release}/files/sys.config

You can read individual properties as follows:

Val = application:get_env(APP, KEY)

Alternatively, all properties for your application can be read as

Config = application:get_all_env(APP)

In sys.config, properties can be added as a proplist.

Example:

    {myapp,
      [
       {port, 1234},
       {pool_size, 5}
      ]
    }


来源:https://stackoverflow.com/questions/9242643/where-should-you-put-application-properties-in-a-rebar-erlang-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!