Start elixir shell

iex --sname node --cookie secret_token -S mix

iex(node@noname)> Node.self :node@noname iex(node@noname)> Node.get_cookie :secret_token

iex --sname node2

iex(node2@noname)> :net_adm.ping(:node@noname) :pang

iex(node2@noname)> Node.set_cookie :secret_token true iex(node2@noname)> :net_adm.ping(:node@noname) :pong

Connect to remote shell using Job Control Mode JCL

iex(node2@noname)> User switch command --> Display help message: iex(node2@noname)> User switch command --> h c [nn] - connect to job i [nn] - interrupt job k [nn] - kill job j - list all jobs s [shell] - start local shell r [node [shell]] - start remote shell q - quit erlang ? | h - this message

--> j 1* {erlang,apply,[#Fun,[]]}

--> r node@noname 'Elixir.IEx'

--> j 1 {erlang,apply,[#Fun,[]]} 2* {node@noname,'Elixir.IEx',start,[]}

--> c 2 Eshell V5.10.2 (abort with ^G) iex(node@noname)>

iex(node@noname)> Node.self :node@noname

Disconnect node

User switch command --> j 1 {erlang,apply,[#Fun,[]]} 2* {node@noname,shell,start,[]}

k 2 --> j 1 {erlang,apply,[#Fun,[]]}

--> c 1 iex(node2@noname)> Node.self :node2@noname

Elixir is a functional language built on top of Erlang VM. Therefore it uses Erlang mechanism for communication with nodes. Erlang has one simple rule: everyone connects to everyone. It provides a simple authentication mechanism by tokens called cookie. In this article I want to show how to use remote shell for interconnection between Elixir nodes.We use sname and cookie parameters to specify short name and cookie. Make sure that settings were applied successfully:Start another shell, but without cookie:In this shell we’ll use Node module to set cookie. We can try to ping our first node::pang atom was returned because cookies weren’t matched and connection wasn’t established. Setup identical cookie for the second node and try again:Activate this mode using Control + G:Show list of jobs:We have only one job which is our current shell. Start remote Elixir shell:Very important to specify the second parameter as Elixir.IEx module, otherwise Erlang shell will be started instead of Elixir.Make sure that the shell was started:Connect to job number 2 which is our first node:Succeed! Make sure that we were connected to the right node:Now we’re able to monitor, change configuration, execute any code in the connected node.Once all the work was done, don’t forget to disconnect remote shell in the right way. Press Control + G:Kill job number 2 and make sure that shell was disconnectedAnd switch back to second node: