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
|
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>slave</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>slave</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
slave</UL>
<H3>MODULE SUMMARY</H3>
<UL>
Functions to Starting and Controlling Slave Nodes
</UL>
<H3>DESCRIPTION</H3>
<UL>
<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.
</UL>
<H3>EXPORTS</H3>
<P><A NAME="start%1"><STRONG><CODE>start(Host)
</CODE></STRONG></A><BR>
<UL>
<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>.</UL>
<P><A NAME="start_link%1"><STRONG><CODE>start_link(Host)
</CODE></STRONG></A><BR>
<UL>
<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>.</UL>
<P><A NAME="start%2"><STRONG><CODE>start(Host, Name)
</CODE></STRONG></A><BR>
<UL>
<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>.</UL>
<P><A NAME="start_link%2"><STRONG><CODE>start_link(Host, Name)
</CODE></STRONG></A><BR>
<UL>
<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>.</UL>
<P><A NAME="start%3"><STRONG><CODE>start(Host, Name, Args) -> {ok, Node} | {error, ErrorInfo}
</CODE></STRONG></A><BR>
<UL>
<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><BR>
<LI>to run some specific program on the slave</LI><BR>
<LI>to set some specific code path on the slave node.</LI><BR>
</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><BR>
<LI>the Mnesia directory should be set to <CODE>M</CODE>;
<BR>
</LI><BR>
<LI>the unix DISPLAY environment variable should be
set to the display of the master node.
<BR>
</LI><BR>
</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><BR>
<LI> the file system on the other host has a different structure to the the master</LI><BR>
<LI>the Erlang nodes have different cookies.</LI><BR>
</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>
</UL>
<P><A NAME="start_link%3"><STRONG><CODE>start_link(Host, Name, Args)
</CODE></STRONG></A><BR>
<UL>
<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>.</UL>
<P><A NAME="stop%1"><STRONG><CODE>stop(Node)
</CODE></STRONG></A><BR>
<UL>
<P>Stops (kills) a node.
</UL>
<P><A NAME="pseudo%1"><STRONG><CODE>pseudo([Master | ServerList])
</CODE></STRONG></A><BR>
<UL>
<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>
</UL>
<P><A NAME="pseudo%2"><STRONG><CODE>pseudo(Master, ServerList)
</CODE></STRONG></A><BR>
<UL>
<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></UL>
<P><A NAME="relay%1"><STRONG><CODE>relay(Pid)
</CODE></STRONG></A><BR>
<UL>
<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>.
</UL>
<H3>AUTHORS</H3>
<UL>
Claes Wikström - support@erlang.ericsson.se<BR>
Björn Gustavsson - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright © 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>
|