O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming Nodes

So far we haven’t needed to give our node a name—we’ve had only one. If we ask Elixir what the current node is called, it’ll give us a made-up name:

 
iex>​ Node.self
 
:nonode@nohost

We can set the name of a node when we start it. With iex, use either the --name or --sname option. The former sets a fully qualified name:

 
$ ​iex --name wibble@light-boy.local
 
iex(wibble@light-boy.local)> Node.self
 
:"wibble@light-boy.local"

The latter sets a short name.

The name that’s returned is an atom—it’s in quotes because it contains characters not allowed in a literal atom.

 
$ ​iex --sname wobble
 
iex(wobble@light-boy)> Node.self
 
:"wobble@light-boy"

Note that in both cases the iex prompt contains the node’s name along with my machine’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required