Starts a slave node on host Host
. Host names need not necessarily be specified as fully qualified names; short names can also be used. This is the same condition that applies to names of distributed Erlang nodes.
The name of the started node becomes Name@Host
. If no name is provided, the name becomes the same as the node that executes the call (except the host name part of the node name).
The slave node resets its user
process so that all terminal I/O that is produced at the slave is automatically relayed to the master. Also, the file process is relayed to the master.
Argument Args
is used to set erl
command-line arguments. If provided, it is passed to the new node and can be used for a variety of purposes; see erl(1)
.
As an example, suppose that you want to start a slave node at host H
with node name Name@H
and want the slave node to have the following properties:
- Directory
Dir
is to be added to the code path.
- The Mnesia directory is to be set to
M
.
- The Unix
DISPLAY
environment variable is to be set to the display of the master node.
The following code is executed to achieve this:
E = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ",
Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E,
slave:start(H, Name, Arg).
The function returns {ok, Node}
, where Node
is the name of the new node, otherwise {error, Reason}
, where Reason
can be one of:
-
timeout
-
The master node failed to get in contact with the slave node. This can occur in a number of circumstances:
- Erlang/OTP is not installed on the remote host.
- The file system on the other host has a different structure to the the master.
- The Erlang nodes have different cookies.
-
no_rsh
-
No remote shell program was found on the computer. Note that ssh
is used by default, but this can be overridden with the -rsh
flag.
-
{already_running, Node}
-
A node with name Name@Host
already exists.