[英]Erlang: set node name that is persistent across host changes
I have a laptop that uses a VPN, and my hostname often changes. 我有一台使用VPN的笔记本电脑,而且我的主机名经常更改。 I get a different Erlang node name every time this happens.
每当发生这种情况时,我都会得到一个不同的Erlang节点名称。 The docs for node ( http://erlang.org/doc/reference_manual/distributed.html ) do not seem to specify a way to set this statically.
节点的文档( http://erlang.org/doc/reference_manual/distributed.html )似乎并未指定静态设置此方法的方法。
How can I permanently configure my machine's nodename to be persistent across network changes? 如何永久配置机器的节点名,使其在网络更改中保持不变?
If you are using Rebar, you should have a vm.args
somewhere and you can set the -sname my_permanent_node_name
flag in here. 如果使用的是Rebar,则应该在某个地方有一个
vm.args
,并且可以在此处设置-sname my_permanent_node_name
标志。
Note that no communication can exist between nodes running with flag -sname and those running with flag -name. 请注意,使用标志-sname运行的节点与使用标志-name运行的节点之间不能存在通信。
Will still accept Asier's answer as it solved it for running normally. 解决了正常运行后仍会接受Asier的回答。
Adding this because when running rebar3 ct
, I hit this issue: http://erlang.org/pipermail/erlang-questions/2016-March/088414.html . 添加此代码是因为在运行
rebar3 ct
时遇到了以下问题: http : rebar3 ct
。 That is, rebar3 ct
does not respect the rebar.config
node name. 也就是说,
rebar3 ct
不遵守rebar.config
节点名称。 I was able to solve this problem using an answer in that mailing thread: 我能够在该邮件线程中使用答案来解决此问题:
set -x REBAR3_ERL_ARGS "-sname myapp@localhost"; rebar3 local install; env DEBUG=1 ~/.cache/rebar3/bin/rebar3 ct
So combined with these two answers I solved the problem. 因此,结合这两个答案,我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.