slave(3)
π
slave β bestie, let's talk π
okay so you opened the manual page for slave from Erlang's stdlib, section 3, and honestly? iconic module, kind of a cursed name, we move. π
β¨ NAME β¨
slave β this module is literally just the functions for starting Erlang slave nodes. that's it, that's the whole vibe. π¦
πΈ DESCRIPTION πΈ
okay so here's the tea, bestie, listen up:
- Every single slave node you start with a master automatically terminates when the master terminates. no lingering, no ghosting, periodt. π
- All terminal output produced at the slave gets sent right back to the master node. π«Ά
- File I/O? done through the master. yes queen, delegation. π
Slave nodes on hosts that aren't the current one get started with the ssh program. The user has to be allowed to ssh to the remote hosts without being prompted for a password. You can arrange that in a number of ways (for the details, go read the ssh documentation, iykyk). A slave node started on the same host as the master inherits certain environment values from the master, like the current directory and the environment variables. And for what you can assume about the environment when a slave is started on another host? that's also in the documentation for the ssh program. π
You can specify an alternative to the ssh program on the command line to erl(1), like this:
-rsh Program
β οΈ Heads up bestie β the command you pass with the-rshflag is treated as a file name which may contain spaces. So it is not possible to include any command line options. The remote node gets launched as"$RSH" "$REMOTE_HOSTNAME" erl -detached -noinput ..., which means theerlcommand must be found in the path on the remote host. no shortcuts, sorry babe. π
The slave node is supposed to use the same file system as the master. At minimum, 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, no mix and match. π₯
A node running on Windows can only start slave nodes on the host on which it is running. windows stays local, that's the rule. πͺ
And the master node must be alive. that's the whole plot twist. don't try it otherwise. π
π FUNCTIONS π
pseudo([Master :: node() | (ServerList :: [atom()])]) -> ok.
π Deprecated:slave:pseudo/1is deprecated; use thepeermodule instead.
Calls pseudo(Master, ServerList). And if you want to start a node from the command line and set up a number of pseudo servers, you can start an Erlang runtime system like this:
% erl -name abc -s slave pseudo klacke@super x --
pseudo(Master, ServerList) -> okwithMaster :: node(), ServerList :: [atom()].
π Deprecated:slave:pseudo/2is deprecated; use thepeermodule instead.
Starts a number of pseudo servers. And what even is a pseudo server, you ask? bestie it's a server with a registered name that does literally nothing except pass on all messages 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 stand-in, it's giving understudy energy, it's giving main character's body double. π
Example time: say you started a slave node N and you want to execute pxw graphics code on this node. You can start server pxw_server as a pseudo server at the slave node, illustrated like this:
rpc:call(N, slave, pseudo, [node(), [pxw_server]]).
relay(Pid) -> no_return() when Pid :: pid().
π Deprecated:slave:relay/1is deprecated; use thepeermodule instead.
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. no thoughts, head empty, just forwarding. β¨
start(Host) -> {ok, Node} | {error, Reason}withHost :: inet:hostname(), Node :: node(), Reason :: timeout | no_rsh | {already_running, Node}.
π Deprecated:slave:start/1is deprecated; use thepeermodule instead.
Equivalent to start(Host, Name) where Name is the same as the node that executes this call.
start(Host) -> {ok, Node} | {error, Reason}
when
Host :: inet:hostname(),
Node :: node(),
Reason :: timeout | no_rsh | {already_running, Node}.
start(Host, Name, Args) -> {ok, Node} | {error, Reason}withHost :: inet:hostname(), Name :: atom() | string(), Args :: string(), Node :: node(), Reason :: timeout | no_rsh | {already_running, Node}.
π Deprecated:slave:start/3is deprecated; use thepeermodule instead.
start(Host, Name, Args) -> {ok, Node} | {error, Reason}
when
Host :: inet:hostname(),
Name :: atom() | string(),
Args :: string(),
Node :: node(),
Reason :: timeout | no_rsh | {already_running, Node}.
Starts a slave node on host Host. Bestie, host names do not need to necessarily be specified as fully qualified names β short names work too. same condition that applies to names of distributed Erlang nodes, so you know the drill. π¦
The name of the started node becomes Name@Host.
The slave node resets its io:user/0 process so that all terminal I/O produced at the slave is automatically relayed to the master. Also, the file server is relayed to the master. everything comes home to mama. π
Argument Args is used to set erl command-line arguments. It's passed to the new node and can be used for a variety of purposes; see erl(1).
Okay example time, because this one ate. Suppose you want to start a slave node at host H with node name Name@H and you want the slave node to have these 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, Name, Args) -> {ok, Node} | {error, Reason}withHost :: inet:hostname(), Name :: atom() | string(), Args :: string(), Node :: node(), Reason :: timeout | no_rsh | {already_running, Node}.
π Deprecated:slave:start_link/3is deprecated; use thepeermodule instead.
start_link(Host, Name, Args) -> {ok, Node} | {error, Reason}
when
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. ride or die, fr fr. π
For a description of arguments and return values, see start/1,2,3.
stop(Node) -> ok when Node :: node().
π Deprecated:slave:stop/1is deprecated; use thepeermodule instead.
Stops (kills) a node. that's the whole thing. brutal, efficient, iconic. π
and that's the page, bestie!! this gem was brought to you by Ericsson AB, running stdlib 8.0.4, and yes, it's the slave(3) manual page. mwah. πβ¨
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms