slave(3erl)
π NAME π
slave(3erl) β Erlang Module Definition, bestie. The module is slave, and it's literally all about functions for starting and controlling slave nodes. π
π¦ DESCRIPTION π¦
This module gives you functions for starting Erlang slave nodes. All slave nodes that are started by a master terminate automatically when the master terminates. Like, the whole squad goes down together. π
All terminal output produced at the slave is sent back to the master node. File I/O is done through the master too. So the master is very much the main character here. π
Slave nodes on other hosts than the current one are started with the ssh program. The user must be allowed to ssh to the remote hosts without being prompted for a password. This can be arranged in a number of ways (for details, see the ssh documentation). A slave node started on the same host as the master inherits certain environment values from the master, such as the current directory and the environment variables. For what can be assumed about the environment when a slave is started on another host, see the documentation for the ssh program. π§
An alternative to the ssh program can be specified on the command line to erl(1) as follows:
-rsh Program
Note that the command specified with the-rshflag is treated as a file name which may contain spaces. It is thus not possible to include any command line options. The remote node will be launched as"$RSH" "$REMOTE_HOSTNAME" erl -detached -noinput ..., so theerlcommand must be found in the path on the remote host. No cap. π
The slave node is to use the same file system at the master. At least, Erlang/OTP is to be installed in the same place on both computers and the same version of Erlang is to be used. Matching set, bestie. π
A node running on Windows can only start slave nodes on the host on which it is running. That's the rule. πͺ
The master node must be alive. Like, actually alive. β¨
β‘ EXPORTS β‘
π pseudo([Master | ServerList]) -> ok π
Types:
Master = node()
ServerList = [atom()]
Calls pseudo(Master, ServerList). If you want to start a node from the command line and set up a number of pseudo servers, an Erlang runtime system can be started as follows:
% erl -name abc -s slave pseudo klacke@super x --
πΈ pseudo(Master, ServerList) -> ok πΈ
Types:
Master = node()
ServerList = [atom()]
Starts a number of pseudo servers. A pseudo server is a server with a registered name that does nothing but pass on all message to the real server that executes at a master node. A pseudo server is an intermediary that only has the same registered name as the real server. It's giving "name-holder with zero extra responsibilities." π
For example, if you have started a slave node N and want to execute pxw graphics code on this node, you can start server pxw_server as a pseudo server at the slave node. This is illustrated as follows:
rpc:call(N, slave, pseudo, [node(), [pxw_server]]).
π¦ relay(Pid) -> no_return() π¦
Types:
Pid = pid()
Runs a pseudo server. This function never returns any value and the process that executes the function receives messages. All messages received are simply passed on to Pid. It's just a little message relay, periodt. π¨
π₯ start(Host) -> {ok, Node} | {error, Reason} π₯
π₯ start(Host, Name) -> {ok, Node} | {error, Reason} π₯
π₯ start(Host, Name, Args) -> {ok, Node} | {error, Reason} π₯
Types:
Host = inet:hostname()
Name = atom() | string()
Args = string()
Node = node()
Reason = timeout | no_rsh | {already_running, Node}
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). Cute and consistent. β¨
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
Diris to be added to the code path. - The Mnesia directory is to be set to
M. - The Unix
DISPLAYenvironment 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 thatsshis used by default, but this can be overridden with the-rshflag.{already_running, Node}β A node with nameName@Hostalready exists.
π start_link(Host) -> {ok, Node} | {error, Reason} π
π start_link(Host, Name) -> {ok, Node} | {error, Reason} π
π start_link(Host, Name, Args) -> {ok, Node} | {error, Reason} π
Types:
Host = inet:hostname()
Name = atom() | string()
Args = string()
Node = node()
Reason = timeout | no_rsh | {already_running, Node}
Starts a slave node in the same way as start/1,2,3, except that the slave node is linked to the currently executing process. If that process terminates, the slave node also terminates. Linked means linked, bestie. If you go down, it goes down too. π
For a description of arguments and return values, see start/1,2,3.
π stop(Node) -> ok π
Types:
Node = node()
Stops (kills) a node. Dramatic? Yes. Accurate? Also yes. π
Signed off by Ericsson AB, stdlib 4.3.1.3, on the slave(3erl) page. Date? The footer didn't give one, so we're just gonna vibe. π
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms