gpt4 book ai didi

erlang - 在启动时动态设置节点名称

转载 作者:行者123 更新时间:2023-12-02 02:35:19 32 4
gpt4 key购买 nike

我正在使用 relx 构建我的版本,但无法使用默认的 -sname someuser@127.0.0.1。相反,我想做类似 -sname someuser@`hostname -i` 的操作来在启动时定义节点的公共(public) IP。使用 -sname someuser@hostname -i`` 不起作用,因为 hostname -i 未扩展为真实 IP。我尝试使用 net_kernel:start(xxxxxxx) 但没有成功。

有没有办法使用 relx 在 vm.args 中获取动态 -sname

谢谢:)

最佳答案

如所写in the documentation (并在 @Soup d'Campbells 的评论中回答),-sname-name 标志不需要主机名,并且将使用主机的 sid 自动填充节点 ID 的 Host 部分(对于 -sname 来说,短格式不完全限定,对于 -name 来说,FQDN 不完全限定):

-sname Name Makes the Erlang runtime system into a distributed node, similar to -name, but the host name portion of the node name Name@Host will be the short name, not fully qualified.

This is sometimes the only way to run distributed Erlang if the DNS (Domain Name System) is not running. There can be no communication between nodes running with the -sname flag and those running with the -name flag, as node names must be unique in distributed Erlang systems.

-name Name Makes the Erlang runtime system into a distributed node. This flag invokes all network servers necessary for a node to become distributed. See net_kernel(3). It is also ensured that epmd runs on the current host before Erlang is started. See epmd(1).

The name of the node will be Name@Host, where Host is the fully qualified host name of the current host. For short names, use the -sname flag instead.

如果您计划使用分布式节点,并且您的域中确实有 DNS,请使用 -name 标志,因为它还将调用所有必要的网络服务器(如上所述)。

亲自看看:

$> erl -sname bouly
(bouly@myserver)1>

$> erl -name bouly
(bouly@myserver.myhome.net)1>

关于erlang - 在启动时动态设置节点名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24916967/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com