File: slave.html

package info (click to toggle)
erlang-doc-html 1%3A11.b.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 23,284 kB
  • ctags: 10,724
  • sloc: erlang: 505; ansic: 323; makefile: 62; perl: 61; sh: 45
file content (330 lines) | stat: -rw-r--r-- 9,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.3 -->
<HTML>
<HEAD>
  <TITLE>slave</TITLE>
  <SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
  <STYLE TYPE="text/css">
<!--
    .REFBODY     { margin-left: 13mm }
    .REFTYPES    { margin-left: 8mm }
-->
  </STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
      ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
  <IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>slave</H1>
</CENTER>

<H3>MODULE</H3>
<DIV CLASS=REFBODY>
slave
</DIV>

<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
Functions to Starting and Controlling Slave Nodes

</DIV>

<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>

<P>This module provides functions for starting Erlang slave nodes.
All slave nodes which are started by a master will terminate
automatically when the master terminates. All TTY output produced
at the slave will be sent back to the master node. File I/O is
done via the master.
<P>Slave nodes on other hosts than the current one are started with
the program <CODE>rsh</CODE>. The user must be allowed to <CODE>rsh</CODE> to
the remote hosts without being prompted for a password. This can
be arranged in a number of ways (refer to the <CODE>rsh</CODE>
documentation for details). 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, read the documentation for the <CODE>rsh</CODE>
program.

<P>An alternative to the <CODE>rsh</CODE> program can be specified on
the command line to <CODE>erl</CODE> as follows: <CODE>-rsh Program</CODE>.

<P>The slave node should use the same file system at the master. At
least, Erlang/OTP should be installed in the same place on both
computers and the same version of Erlang should be used.
<P>Currently, a node running on Windows NT can only start slave
nodes on the host on which it is running.
<P>The master node must be alive.
</DIV>

<H3>EXPORTS</H3>

<P><A NAME="start/1"><STRONG><CODE>start(Host) -&#62;</CODE></STRONG></A><BR>
<A NAME="start/2"><STRONG><CODE>start(Host, Name) -&#62;</CODE></STRONG></A><BR>
<A NAME="start/3"><STRONG><CODE>start(Host, Name, Args) -&#62; {ok, Node} | {error, Reason}
</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Host = Name = atom()</CODE></STRONG><BR>
<STRONG><CODE>Args = string()</CODE></STRONG><BR>
<STRONG><CODE>Node = node()</CODE></STRONG><BR>
<STRONG><CODE>Reason = timeout | no_rsh | {already_running, Node}</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Starts a slave node on the host <CODE>Host</CODE>. 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.
<P>The name of the started node will be <CODE>Name@Host</CODE>. If no
         name is provided, the name will be the same as the node which
         executes the call (with the exception of the host name part of
         the node name).
<P>The slave node resets its <CODE>user</CODE> process so that all
         terminal I/O which is produced at the slave is automatically 
         relayed to the master. Also, the file process will be relayed
         to the master.
<P>The <CODE>Args</CODE> argument is used to set <CODE>erl</CODE> command
         line arguments. If provided, it is passed to the new node and
         can be used for a variety of purposes. See
         <A HREF="javascript:erlhref('../../../../', 'erts', 'erl.html#erl');">erl(1)</A>
<P>As an example, suppose that we want to start a slave node at
         host <CODE>H</CODE> with the node name <CODE>Name@H</CODE>, and we also
         want the slave node to have the following properties:
<P>
<UL>

<LI>
         directory <CODE>Dir</CODE> should be added to the code path;
         <BR>

         
</LI>


<LI>
         the Mnesia directory should be set to <CODE>M</CODE>;<BR>

         
</LI>


<LI>
         the unix <CODE>DISPLAY</CODE> environment variable should be
         set to the display of the master node.<BR>

         
</LI>


</UL>

<P>The following code is executed to achieve this:
<PRE>
E = &#34; -env DISPLAY &#34; ++ net_adm:localhost() ++ &#34;:0 &#34;,
Arg = &#34;-mnesia_dir &#34; ++ M ++ &#34; -pa &#34; ++ Dir ++ E,
slave:start(H, Name, Arg).
        
</PRE>

<P>If successful, the function returns <CODE>{ok, Node}</CODE>,
         where <CODE>Node</CODE> is the name of the new node. Otherwise it
         returns <CODE>{error, Reason}</CODE>, where <CODE>Reason</CODE> can be
         one of:
<P>
<DL>

<DT>
<CODE>timeout</CODE>
</DT>

<DD>
 The master node failed to get in contact with the slave
         node. This can happen in a number of circumstances:<BR>

         
<UL>

<LI>
Erlang/OTP is not installed on the remote host
</LI>


<LI>
the file system on the other host has a different
                structure to the the master
</LI>


<LI>
the Erlang nodes have different cookies.
</LI>


</UL>

         
</DD>

<DT>
<CODE>no_rsh</CODE>
</DT>

<DD>
 There is no <CODE>rsh</CODE> program on the computer.<BR>

         
</DD>

<DT>
<CODE>{already_running, Node}</CODE>
</DT>

<DD>
 A node with the name <CODE>Name@Host</CODE> already exists.<BR>

         
</DD>

</DL>

</DIV>

<P><A NAME="start_link/1"><STRONG><CODE>start_link(Host) -&#62;</CODE></STRONG></A><BR>
<A NAME="start_link/2"><STRONG><CODE>start_link(Host, Name) -&#62;</CODE></STRONG></A><BR>
<A NAME="start_link/3"><STRONG><CODE>start_link(Host, Name, Args) -&#62; {ok, Node} | {error, Reason}
</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Host = Name = atom()</CODE></STRONG><BR>
<STRONG><CODE>Args = string()</CODE></STRONG><BR>
<STRONG><CODE>Node = node()</CODE></STRONG><BR>
<STRONG><CODE>Reason = timeout | no_rsh | {already_running, Node}</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Starts a slave node in the same way as <CODE>start/1,2,3</CODE>,
         except that the slave node is linked to the currently
         executing process. If that process terminates, the slave node
         also terminates.
<P>See <CODE>start/1,2,3</CODE> for a description of arguments and
         return values.
</DIV>

<P><A NAME="stop/1"><STRONG><CODE>stop(Node) -&#62; ok</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Node = node()</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Stops (kills) a node.
</DIV>

<P><A NAME="pseudo/1"><STRONG><CODE>pseudo([Master | ServerList]) -&#62; ok</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Master = node()</CODE></STRONG><BR>
<STRONG><CODE>ServerList = [atom()]</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Calls <CODE>pseudo(Master, ServerList)</CODE>. If we 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:
<PRE>
% erl -name abc -s slave pseudo klacke@super x --
        
</PRE>

</DIV>

<P><A NAME="pseudo/2"><STRONG><CODE>pseudo(Master, ServerList) -&#62; ok</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Master = node()</CODE></STRONG><BR>
<STRONG><CODE>ServerList = [atom()]</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Starts a number of pseudo servers. A pseudo server is a
         server with a registered name which does absolutely nothing
         but pass on all message to the real server which executes at a
         master node. A pseudo server is an intermediary which only has
         the same registered name as the real server.
<P>For example, if we have started a slave node <CODE>N</CODE> and
         want to execute <CODE>pxw</CODE> graphics code on this node, we can
         start the server <CODE>pxw_server</CODE> as a pseudo server at
         the slave node. The following code illustrates:
<PRE>
rpc:call(N, slave, pseudo, [node(), [pxw_server]]).
        
</PRE>

</DIV>

<P><A NAME="relay/1"><STRONG><CODE>relay(Pid)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Pid = pid()</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Runs a pseudo server. This function never returns any value
         and the process which executes the function will receive
         messages. All messages received will simply be passed on to
         <CODE>Pid</CODE>.
</DIV>

<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Claes Wikstrom - support@erlang.ericsson.se<BR>
Bjorn Gustavsson - support@erlang.ericsson.se<BR>

</DIV>
<CENTER>
<HR>
<SMALL>stdlib 1.14.2<BR>
Copyright &copy; 1991-2006
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>