Erlang:如何重新加载应用程序环境配置?

发布于 2024-09-02 04:30:04 字数 144 浏览 2 评论 0原文

如何重新加载应用程序的配置?或者,管理动态应用程序配置的好策略是什么?

例如,假设我有日志级别,并且我想在运行时更改它们。另外,我们假设这是许多此类选项之一。拥有一个保存配置状态以供应用程序其他部分查询的“配置服务器”是否有意义?是人们这么做的还是我编造的?

How do you reload an application's configuration? Or, what are good strategies for managing dynamic application configuration?

For example, let's say I had log levels and I wanted to change them at runtime. Also, let's assume this is one of many such options. Does it make sense to have a "configuration server" that holds configuration state for other parts of the application to query? Do people do that or did I just make it up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屋檐 2024-09-09 04:30:04

我认为将所有配置数据保存在存储库(subversion、mercurial 等)中并让应用程序在每次启动或尝试重新加载一些其配置选项时下载它是合理的。这是集中式方法 - 但是您可以拥有许多配置服务器来避免SPOF - 并且它:

  • 允许您跟踪变化,以便您
    知道是谁放的以及他何时放的
    那个(没有人愿意负责
    配置不正确);
  • 使您能够使用相同的配置
    您身边的所有应用程序
    网络;
  • 更改的容易程度:只需修改即可
    配置并通知相关应用程序
    使用 gen_server:abcast 调用或其他方式。

proplists(3) 在读取配置时很有用。

I believe it's reasonable to keep all your configuration data in a repository (subversion, mercurial etc.) and have applications download it every time they start or attempt to reload some their configuration options. This is centralized approach — however you could have many configuration servers to avoid SPOF — and it:

  • allows you to keep track of changes so that you
    know who put these and when (s)he did
    that (none wants to be in charge of
    unproper configuration);
  • enables you to use the same configuration for
    all applications throughout you
    network;
  • easiness of changes: you can just modify
    configuration and notify concerned applications
    using gen_server:abcast call or other means.

proplists(3) are useful when reading configuration.

把昨日还给我 2024-09-09 04:30:04

如果我的理解是正确的,那么问题如下:

你想要创建一个分布式、可扩展的系统,当然Erlang是你想到的第一选择,因为它就是为此目的而设计的。

  • < p>您将有多个节点,它们将运行本地应用程序和分布式应用程序。

  • 这里最简单的层次结构是为每个主要功能提供热备用备份。

  • 这可以通过实现分布式应用程序控制器来实现。

    • 最简单的示例是在节点上启动服务器,同时在配合节点上启动从属服务器。

    • 分布式应用程序控制器有很多优点。

      • 简单的例子是通过引入新消息来以不同的方式处理node_up消息,这些新消息表明节点不仅已准备好erlang VM,而且所有重要应用程序都在运行。这样,配对节点就可以确定备用节点已准备好并可以开始同步。

如果我误解了什么,请详细说明或评论。
祝你好运!

If my understanding is correct, the problem is the following:

You want to create a distributed, scalable system and of course Erlang is the first choice that comes into mind, since it was designed for such purposes.

  • You will have several nodes that will be running local applications and also distributed applications as well.

  • Here the simplest hierarchy is to have a hot-standby backup for every major functionality.

  • This can be achieved by implementing a distributed application controller.

    • Simplest example is to have a server start on a node, while a slave server is started simultaneously on a mate node.

    • Distributed Application controllers have many advantages.

      • Easy example is to handle node_up messages differently by introducing new messages that indicate that a node is not only erlang VM ready, but all vital applications are running. This way the mate node can be sure that the stand-by node is ready and can start sync-ing.

Please elaborate or comment if I misunderstood something.
Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文