1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
9
<holder>Ericsson AB, All Rights Reserved</holder>
12
The contents of this file are subject to the Erlang Public License,
13
Version 1.1, (the "License"); you may not use this file except in
14
compliance with the License. You should have received a copy of the
15
Erlang Public License along with this software. If not, it can be
16
retrieved online at http://www.erlang.org/.
18
Software distributed under the License is distributed on an "AS IS"
19
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
20
the License for the specific language governing rights and limitations
23
The Initial Developer of the Original Code is Ericsson AB.
32
<module>slave</module>
33
<modulesummary>Functions to Starting and Controlling Slave Nodes</modulesummary>
35
<p>This module provides functions for starting Erlang slave nodes.
36
All slave nodes which are started by a master will terminate
37
automatically when the master terminates. All TTY output produced
38
at the slave will be sent back to the master node. File I/O is
39
done via the master.</p>
40
<p>Slave nodes on other hosts than the current one are started with
41
the program <c>rsh</c>. The user must be allowed to <c>rsh</c> to
42
the remote hosts without being prompted for a password. This can
43
be arranged in a number of ways (refer to the <c>rsh</c>
44
documentation for details). A slave node started on the same host
45
as the master inherits certain environment values from the master,
46
such as the current directory and the environment variables. For
47
what can be assumed about the environment when a slave is started
48
on another host, read the documentation for the <c>rsh</c>
50
<p>An alternative to the <c>rsh</c> program can be specified on
51
the command line to <c>erl</c> as follows: <c>-rsh Program</c>.</p>
52
<p>The slave node should use the same file system at the master. At
53
least, Erlang/OTP should be installed in the same place on both
54
computers and the same version of Erlang should be used.</p>
55
<p>Currently, a node running on Windows NT can only start slave
56
nodes on the host on which it is running.</p>
57
<p>The master node must be alive.</p>
61
<name>start(Host) -></name>
62
<name>start(Host, Name) -></name>
63
<name>start(Host, Name, Args) -> {ok, Node} | {error, Reason}</name>
64
<fsummary>Start a slave node on a host</fsummary>
66
<v>Host = Name = atom()</v>
67
<v>Args = string()</v>
69
<v>Reason = timeout | no_rsh | {already_running, Node}</v>
72
<p>Starts a slave node on the host <c>Host</c>. Host names need
73
not necessarily be specified as fully qualified names; short
74
names can also be used. This is the same condition that
75
applies to names of distributed Erlang nodes.</p>
76
<p>The name of the started node will be <c>Name@Host</c>. If no
77
name is provided, the name will be the same as the node which
78
executes the call (with the exception of the host name part of
80
<p>The slave node resets its <c>user</c> process so that all
81
terminal I/O which is produced at the slave is automatically
82
relayed to the master. Also, the file process will be relayed
84
<p>The <c>Args</c> argument is used to set <c>erl</c> command
85
line arguments. If provided, it is passed to the new node and
86
can be used for a variety of purposes. See
87
<seealso marker="erts:erl#erl">erl(1)</seealso></p>
88
<p>As an example, suppose that we want to start a slave node at
89
host <c>H</c> with the node name <c>Name@H</c>, and we also
90
want the slave node to have the following properties:</p>
91
<list type="bulleted">
93
<p>directory <c>Dir</c> should be added to the code path;</p>
96
<p>the Mnesia directory should be set to <c>M</c>;</p>
99
<p>the unix <c>DISPLAY</c> environment variable should be
100
set to the display of the master node.</p>
103
<p>The following code is executed to achieve this:</p>
105
E = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ",
106
Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E,
107
slave:start(H, Name, Arg).</code>
108
<p>If successful, the function returns <c>{ok, Node}</c>,
109
where <c>Node</c> is the name of the new node. Otherwise it
110
returns <c>{error, Reason}</c>, where <c>Reason</c> can be
113
<tag><c>timeout</c></tag>
115
<p>The master node failed to get in contact with the slave
116
node. This can happen in a number of circumstances:</p>
117
<list type="bulleted">
118
<item>Erlang/OTP is not installed on the remote host</item>
119
<item>the file system on the other host has a different
120
structure to the the master</item>
121
<item>the Erlang nodes have different cookies.</item>
124
<tag><c>no_rsh</c></tag>
126
<p>There is no <c>rsh</c> program on the computer.</p>
128
<tag><c>{already_running, Node}</c></tag>
130
<p>A node with the name <c>Name@Host</c> already exists.</p>
136
<name>start_link(Host) -></name>
137
<name>start_link(Host, Name) -></name>
138
<name>start_link(Host, Name, Args) -> {ok, Node} | {error, Reason}</name>
139
<fsummary>Start and link to a slave node on a host</fsummary>
141
<v>Host = Name = atom()</v>
142
<v>Args = string()</v>
144
<v>Reason = timeout | no_rsh | {already_running, Node}</v>
147
<p>Starts a slave node in the same way as <c>start/1,2,3</c>,
148
except that the slave node is linked to the currently
149
executing process. If that process terminates, the slave node
151
<p>See <c>start/1,2,3</c> for a description of arguments and
156
<name>stop(Node) -> ok</name>
157
<fsummary>Stop (kill) a node</fsummary>
162
<p>Stops (kills) a node.</p>
166
<name>pseudo([Master | ServerList]) -> ok</name>
167
<fsummary>Start a number of pseudo servers</fsummary>
169
<v>Master = node()</v>
170
<v>ServerList = [atom()]</v>
173
<p>Calls <c>pseudo(Master, ServerList)</c>. If we want to start
174
a node from the command line and set up a number of pseudo
175
servers, an Erlang runtime system can be started as
178
% erl -name abc -s slave pseudo klacke@super x --</pre>
182
<name>pseudo(Master, ServerList) -> ok</name>
183
<fsummary>Start a number of pseudo servers</fsummary>
185
<v>Master = node()</v>
186
<v>ServerList = [atom()]</v>
189
<p>Starts a number of pseudo servers. A pseudo server is a
190
server with a registered name which does absolutely nothing
191
but pass on all message to the real server which executes at a
192
master node. A pseudo server is an intermediary which only has
193
the same registered name as the real server.</p>
194
<p>For example, if we have started a slave node <c>N</c> and
195
want to execute <c>pxw</c> graphics code on this node, we can
196
start the server <c>pxw_server</c> as a pseudo server at
197
the slave node. The following code illustrates:</p>
199
rpc:call(N, slave, pseudo, [node(), [pxw_server]]).</code>
203
<name>relay(Pid)</name>
204
<fsummary>Run a pseudo server</fsummary>
209
<p>Runs a pseudo server. This function never returns any value
210
and the process which executes the function will receive
211
messages. All messages received will simply be passed on to