Skip to content

Instantly share code, notes, and snippets.

@lasandell
Last active December 25, 2015 08:59
Show Gist options
  • Save lasandell/6950745 to your computer and use it in GitHub Desktop.
Save lasandell/6950745 to your computer and use it in GitHub Desktop.
Erlang Camp Day 2

Distributed Erlang

Starting Nodes

erl -sname somename

erl -setcookie foo -sname somename

Erlang cookie is not for security, it is only for topology.

Pinging Nodes

net_adm:ping(somename).

Returns pong if found, pang if not found.

Listing Nodes

node().

nodes().

Notes: nodes() does not include self.

Registering processes

register(shell, self()).

unregister(shell).

Note: registration is local. Do not use global registration.

Messageable structures

Here are the specs for messeagable structures:

Pid::pid()

Name::atom()

NameNode::{name, node()}

Here are some examples of using them:

{shell, 'somename@Laptop'} ! {from, node()}

[{name, Node} || Node <- nodes() ]

[{name, Node} ! self() || Node <- nodes()]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment