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 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.2 -->
<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)
</CODE></STRONG></A><BR>
<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.
The name of the started node will be the same as
the node which executes the call, with the exception
of the host name part of the node name.
<P>Return value: see <CODE>start/3</CODE>.
</DIV>
<P><A NAME="start_link/1"><STRONG><CODE>start_link(Host)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a slave node on the host <CODE>Host</CODE> in the same
way as the <CODE>start/1</CODE>, except that the slave node is linked
to the currently executing process.
If the process terminates, the slave node also terminates.
<P>Return value: see <CODE>start/3</CODE>.
</DIV>
<P><A NAME="start/2"><STRONG><CODE>start(Host, Name)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a slave node on the host <CODE>Host</CODE> with the
name <CODE>Name@Host</CODE>.
<P>Return value: see <CODE>start/3</CODE>.
</DIV>
<P><A NAME="start_link/2"><STRONG><CODE>start_link(Host, Name)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a slave node on the host <CODE>Host</CODE> in the same
way as <CODE>start/2</CODE>, except that the slave node is linked
to the currently executing process.
If that process terminates, the slave node also terminates.
<P>Return value: see <CODE>start/3</CODE>.
</DIV>
<P><A NAME="start/3"><STRONG><CODE>start(Host, Name, Args) -> {ok, Node} | {error, ErrorInfo}
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a slave node with the name <CODE>Name@Host</CODE> on <CODE>Host</CODE> and
passes the argument string <CODE>Args</CODE> to the new node.
<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 can be used for a
variety of purposes. See erl(1). For example, the following command line arguments can be passed to the slave:
<P>
<UL>
<LI>
to set some environment variable on the slave
</LI>
<LI>
to run some specific program on the slave
</LI>
<LI>
to set some specific code path on the slave node.
</LI>
</UL>
<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 DISPLAY 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 = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ",
Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E,
slave:start(H, Name, Arg).
</PRE>
<P>The <CODE>start/3</CODE> call returns <CODE>{ok, Name@Host}</CODE> if
successful, otherwise <CODE>{error, Reason}</CODE>.
<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, Name@Host}</CODE>
</DT>
<DD>
A node with the name <CODE>Name@Host</CODE> already exists.
<BR>
</DD>
</DL>
</DIV>
<P><A NAME="start_link/3"><STRONG><CODE>start_link(Host, Name, Args)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a slave node on the host <CODE>Host</CODE> in the same
way as the <CODE>start/3</CODE>, except that the slave node is linked
to the currently executing process.
If that process terminates, the slave node also terminates.
<P>Return value: see <CODE>start/3</CODE>.
</DIV>
<P><A NAME="stop/1"><STRONG><CODE>stop(Node)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Stops (kills) a node.
</DIV>
<P><A NAME="pseudo/1"><STRONG><CODE>pseudo([Master | ServerList])
</CODE></STRONG></A><BR>
<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:
<P>
<PRE>
% erl -name abc -s slave pseudo klacke@super x --
</PRE>
</DIV>
<P><A NAME="pseudo/2"><STRONG><CODE>pseudo(Master, ServerList)
</CODE></STRONG></A><BR>
<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>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 Wikstrm - support@erlang.ericsson.se<BR>
Bjrn Gustavsson - support@erlang.ericsson.se<BR>
</DIV>
<CENTER>
<HR>
<SMALL>stdlib 1.13.2<BR>
Copyright © 1991-2004
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>
|