开发者_如何学CI want to simulate the behavior of erl -sname example -hidden
but dynamically. How can I drop a node out of visibility in a cluster?
See the comments by @mwt at @Yasir Arsanukaev for additional clarification of what I'm trying to do.
Try erlang:disconnect_node/1
:
(bar@dt)1> nodes().
[]
(bar@dt)2> net_adm:ping('foo@dt').
pong
(bar@dt)3> nodes().
[foo@dt]
(bar@dt)4> erlang:disconnect_node('foo@dt').
true
(bar@dt)5> nodes().
[]
Or if you want a node to remove itself from other nodes' nodes()
:
(bar@dt)1> nodes().
[foo@dt]
(bar@dt)2> rpc:eval_everywhere(erlang, disconnect_node, [node()]).
abcast
(bar@dt)3> nodes().
[]
If the node was started with key -hidden
:
(bar@dt)1> nodes(hidden).
[foo@dt]
(bar@dt)2> rpc:eval_everywhere(nodes(hidden), erlang, disconnect_node, [node()]).
abcast
(bar@dt)3> nodes(hidden).
[]
精彩评论