测试节点是否彼此可见?

时间:2016-12-01 11:49:55

标签: erlang elixir

如何检查部署的节点是否可以看到对方? 我试着这样做:

mix edeliver ping production --verbose     

我得到了:

EDELIVER MY_IDEA WITH PING COMMAND

-----> pinging production servers



production node: 0

  user    : bitnami
  host    : xxx
  path    : /home/bitnami
  response: pong

production node: 1

  user    : bitnami
  host    : yyy
  path    : /home/bitnami
  response: pong

我的应用已部署到:

~/my_idea/releases/0.0.1

我知道这可以通过命令行使用erlang Nodes().在elixir中实现吗?但是如何运行附加到正在运行的应用范围的控制台?

1 个答案:

答案 0 :(得分:0)

我认为你所寻找的是一个远程shell。在Erlang中,我通常会使用erl来连接到远程节点:

erl -sname $short_name -setcookie $erlang_cookie -hidden -remsh $remote_node

当然,将$short_name替换为您选择的名称和$erlang_cookie要连接到的节点的Cookie值($remote_node)。

在你的情况下,我会做这样的事情:

# Replace `node0` with the exact node name
erl -sname foobar -setcookie yourcookie -hidden -remsh node0 
# Once in the shell run:
1> net_adm:ping(node1). % Replace with the node name of the other node

如果您获得pong节点可以进行通信。如果得到pang节点无法通信。您还可以尝试运行nodes()以获取已连接节点的列表。

请注意,节点在必须之前不会连接,因此如果它们没有向对方发送任何消息,您将获得一个空列表。成功调用net_adm:ping/1将导致节点位于nodes/0返回的列表中。

有关详细信息,请参阅Distributed Erlang上的文档。