수색…


시스템에 보이는 모든 노드 나열

iex(bob@127.0.0.1)> Node.list
[:"frank@127.0.0.1"]

동일한 시스템에 노드 연결

두 개의 터미널 창에서 두 개의 명명 된 노드를 시작합니다.

>iex --name bob@127.0.0.1
iex(bob@127.0.0.1)>
>iex --name frank@127.0.0.1
iex(frank@127.0.0.1)>

하나의 노드에 연결하도록 지시하여 두 개의 노드를 연결하십시오.

iex(bob@127.0.0.1)> Node.connect :"frank@127.0.0.1"
true

이제 두 개의 노드가 서로 연결되어 서로를 인식합니다.

iex(bob@127.0.0.1)> Node.list
[:"frank@127.0.0.1"]
iex(frank@127.0.0.1)> Node.list
[:"bob@127.0.0.1"]

다른 노드에서 코드를 실행할 수 있습니다.

iex(bob@127.0.0.1)> greet = fn() -> IO.puts("Hello from #{inspect(Node.self)}") end
iex(bob@127.0.0.1)> Node.spawn(:"frank@127.0.0.1", greet)
#PID<9007.74.0>
Hello from :"frank@127.0.0.1"
:ok

다른 시스템에 노드 연결

하나의 IP 주소에서 명명 된 프로세스 시작 :

$ iex --name foo@10.238.82.82 --cookie chocolate
iex(foo@10.238.82.82)> Node.ping :"bar@10.238.82.85"
:pong
iex(foo@10.238.82.82)> Node.list
[:"bar@10.238.82.85"]

다른 IP 주소에서 다른 명명 된 프로세스를 시작하십시오.

$ iex --name bar@10.238.82.85 --cookie chocolate
iex(bar@10.238.82.85)> Node.list
[:"foo@10.238.82.82"]


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow