~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/stdlib/doc/src/slave.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1996</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
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/.
 
17
 
 
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
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>slave</title>
 
27
    <prepared></prepared>
 
28
    <docno></docno>
 
29
    <date></date>
 
30
    <rev></rev>
 
31
  </header>
 
32
  <module>slave</module>
 
33
  <modulesummary>Functions to Starting and Controlling Slave Nodes</modulesummary>
 
34
  <description>
 
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>
 
49
      program.</p>
 
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>
 
58
  </description>
 
59
  <funcs>
 
60
    <func>
 
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>
 
65
      <type>
 
66
        <v>Host = Name = atom()</v>
 
67
        <v>Args = string()</v>
 
68
        <v>Node = node()</v>
 
69
        <v>Reason = timeout | no_rsh | {already_running, Node}</v>
 
70
      </type>
 
71
      <desc>
 
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
 
79
          the node name).</p>
 
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
 
83
          to the master.</p>
 
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">
 
92
          <item>
 
93
            <p>directory <c>Dir</c> should be added to the code path;</p>
 
94
          </item>
 
95
          <item>
 
96
            <p>the Mnesia directory should be set to <c>M</c>;</p>
 
97
          </item>
 
98
          <item>
 
99
            <p>the unix <c>DISPLAY</c> environment variable should be
 
100
              set to the display of the master node.</p>
 
101
          </item>
 
102
        </list>
 
103
        <p>The following code is executed to achieve this:</p>
 
104
        <code type="none">
 
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
 
111
          one of:</p>
 
112
        <taglist>
 
113
          <tag><c>timeout</c></tag>
 
114
          <item>
 
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>
 
122
            </list>
 
123
          </item>
 
124
          <tag><c>no_rsh</c></tag>
 
125
          <item>
 
126
            <p>There is no <c>rsh</c> program on the computer.</p>
 
127
          </item>
 
128
          <tag><c>{already_running, Node}</c></tag>
 
129
          <item>
 
130
            <p>A node with the name <c>Name@Host</c> already exists.</p>
 
131
          </item>
 
132
        </taglist>
 
133
      </desc>
 
134
    </func>
 
135
    <func>
 
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>
 
140
      <type>
 
141
        <v>Host = Name = atom()</v>
 
142
        <v>Args = string()</v>
 
143
        <v>Node = node()</v>
 
144
        <v>Reason = timeout | no_rsh | {already_running, Node}</v>
 
145
      </type>
 
146
      <desc>
 
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
 
150
          also terminates.</p>
 
151
        <p>See <c>start/1,2,3</c> for a description of arguments and
 
152
          return values.</p>
 
153
      </desc>
 
154
    </func>
 
155
    <func>
 
156
      <name>stop(Node) -> ok</name>
 
157
      <fsummary>Stop (kill) a node</fsummary>
 
158
      <type>
 
159
        <v>Node = node()</v>
 
160
      </type>
 
161
      <desc>
 
162
        <p>Stops (kills) a node.</p>
 
163
      </desc>
 
164
    </func>
 
165
    <func>
 
166
      <name>pseudo([Master | ServerList]) -> ok</name>
 
167
      <fsummary>Start a number of pseudo servers</fsummary>
 
168
      <type>
 
169
        <v>Master = node()</v>
 
170
        <v>ServerList = [atom()]</v>
 
171
      </type>
 
172
      <desc>
 
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
 
176
          follows:</p>
 
177
        <pre>
 
178
% erl -name abc -s slave pseudo klacke@super x --</pre>
 
179
      </desc>
 
180
    </func>
 
181
    <func>
 
182
      <name>pseudo(Master, ServerList) -> ok</name>
 
183
      <fsummary>Start a number of pseudo servers</fsummary>
 
184
      <type>
 
185
        <v>Master = node()</v>
 
186
        <v>ServerList = [atom()]</v>
 
187
      </type>
 
188
      <desc>
 
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>
 
198
        <code type="none">
 
199
rpc:call(N, slave, pseudo, [node(), [pxw_server]]).</code>
 
200
      </desc>
 
201
    </func>
 
202
    <func>
 
203
      <name>relay(Pid)</name>
 
204
      <fsummary>Run a pseudo server</fsummary>
 
205
      <type>
 
206
        <v>Pid = pid()</v>
 
207
      </type>
 
208
      <desc>
 
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
 
212
          <c>Pid</c>.</p>
 
213
      </desc>
 
214
    </func>
 
215
  </funcs>
 
216
</erlref>
 
217