1slave(3) Erlang Module Definition slave(3)
2
3
4
6 slave - Functions for starting and controlling slave nodes.
7
8
10 This module provides functions for starting Erlang slave nodes. All
11 slave nodes that are started by a master terminate automatically when
12 the master terminates. All terminal output produced at the slave is
13 sent back to the master node. File I/O is done through the master.
14
15 Slave nodes on other hosts than the current one are started with the
16 rsh program. The user must be allowed to rsh to the remote hosts with‐
17 out being prompted for a password. This can be arranged in a number of
18 ways (for details, see the rsh documentation). A slave node started on
19 the same host as the master inherits certain environment values from
20 the master, such as the current directory and the environment vari‐
21 ables. For what can be assumed about the environment when a slave is
22 started on another host, see the documentation for the rsh program.
23
24 An alternative to the rsh program can be specified on the command line
25 to erl(1) as follows:
26
27 -rsh Program
28
29 The slave node is to use the same file system at the master. At least,
30 Erlang/OTP is to be installed in the same place on both computers and
31 the same version of Erlang is to be used.
32
33 A node running on Windows can only start slave nodes on the host on
34 which it is running.
35
36 The master node must be alive.
37
39 pseudo([Master | ServerList]) -> ok
40
41 Types:
42
43 Master = node()
44 ServerList = [atom()]
45
46 Calls pseudo(Master, ServerList). If you want to start a node
47 from the command line and set up a number of pseudo servers, an
48 Erlang runtime system can be started as follows:
49
50 % erl -name abc -s slave pseudo klacke@super x --
51
52 pseudo(Master, ServerList) -> ok
53
54 Types:
55
56 Master = node()
57 ServerList = [atom()]
58
59 Starts a number of pseudo servers. A pseudo server is a server
60 with a registered name that does nothing but pass on all message
61 to the real server that executes at a master node. A pseudo
62 server is an intermediary that only has the same registered name
63 as the real server.
64
65 For example, if you have started a slave node N and want to exe‐
66 cute pxw graphics code on this node, you can start server
67 pxw_server as a pseudo server at the slave node. This is illus‐
68 trated as follows:
69
70 rpc:call(N, slave, pseudo, [node(), [pxw_server]]).
71
72 relay(Pid) -> no_return()
73
74 Types:
75
76 Pid = pid()
77
78 Runs a pseudo server. This function never returns any value and
79 the process that executes the function receives messages. All
80 messages received are simply passed on to Pid.
81
82 start(Host) -> {ok, Node} | {error, Reason}
83
84 start(Host, Name) -> {ok, Node} | {error, Reason}
85
86 start(Host, Name, Args) -> {ok, Node} | {error, Reason}
87
88 Types:
89
90 Host = inet:hostname()
91 Name = atom() | string()
92 Args = string()
93 Node = node()
94 Reason = timeout | no_rsh | {already_running, Node}
95
96 Starts a slave node on host Host. Host names need not necessar‐
97 ily be specified as fully qualified names; short names can also
98 be used. This is the same condition that applies to names of
99 distributed Erlang nodes.
100
101 The name of the started node becomes Name@Host. If no name is
102 provided, the name becomes the same as the node that executes
103 the call (except the host name part of the node name).
104
105 The slave node resets its user process so that all terminal I/O
106 that is produced at the slave is automatically relayed to the
107 master. Also, the file process is relayed to the master.
108
109 Argument Args is used to set erl command-line arguments. If pro‐
110 vided, it is passed to the new node and can be used for a vari‐
111 ety of purposes; see erl(1).
112
113 As an example, suppose that you want to start a slave node at
114 host H with node name Name@H and want the slave node to have the
115 following properties:
116
117 * Directory Dir is to be added to the code path.
118
119 * The Mnesia directory is to be set to M.
120
121 * The Unix DISPLAY environment variable is to be set to the
122 display of the master node.
123
124 The following code is executed to achieve this:
125
126 E = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ",
127 Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E,
128 slave:start(H, Name, Arg).
129
130 The function returns {ok, Node}, where Node is the name of the
131 new node, otherwise {error, Reason}, where Reason can be one of:
132
133 timeout:
134 The master node failed to get in contact with the slave
135 node. This can occur in a number of circumstances:
136
137 * Erlang/OTP is not installed on the remote host.
138
139 * The file system on the other host has a different struc‐
140 ture to the the master.
141
142 * The Erlang nodes have different cookies.
143
144 no_rsh:
145 There is no rsh program on the computer.
146
147 {already_running, Node}:
148 A node with name Name@Host already exists.
149
150 start_link(Host) -> {ok, Node} | {error, Reason}
151
152 start_link(Host, Name) -> {ok, Node} | {error, Reason}
153
154 start_link(Host, Name, Args) -> {ok, Node} | {error, Reason}
155
156 Types:
157
158 Host = inet:hostname()
159 Name = atom() | string()
160 Args = string()
161 Node = node()
162 Reason = timeout | no_rsh | {already_running, Node}
163
164 Starts a slave node in the same way as start/1,2,3, except that
165 the slave node is linked to the currently executing process. If
166 that process terminates, the slave node also terminates.
167
168 For a description of arguments and return values, see
169 start/1,2,3.
170
171 stop(Node) -> ok
172
173 Types:
174
175 Node = node()
176
177 Stops (kills) a node.
178
179
180
181Ericsson AB stdlib 3.8.2.1 slave(3)