slave 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +164 -26
- data/README.tmpl +83 -0
- data/doc/classes/(@object = Object.new).html +117 -0
- data/doc/classes/(o = Object.new).html +117 -0
- data/doc/classes/@object.html +117 -0
- data/doc/classes/Slave.html +458 -225
- data/doc/classes/Slave/Heartbeat.html +200 -199
- data/doc/classes/o.html +117 -0
- data/doc/classes/object.html +117 -0
- data/doc/created.rid +1 -1
- data/doc/dot/f_0.jpg +0 -0
- data/doc/dot/f_1.dot +9 -0
- data/doc/dot/f_1.jpg +0 -0
- data/doc/files/README.html +200 -45
- data/doc/files/lib/slave_rb.html +4 -2
- data/doc/fr_class_index.html +1 -0
- data/doc/fr_method_index.html +23 -19
- data/gen_readme.rb +32 -0
- data/lib/{slave-0.2.0.rb → slave-1.0.0.rb} +185 -60
- data/lib/slave.rb +185 -60
- data/{sample → samples}/a.rb +7 -10
- data/samples/b.rb +22 -0
- data/samples/c.rb +21 -0
- data/samples/d.rb +9 -0
- data/samples/e.rb +11 -0
- data/slave-1.0.0.gem +0 -0
- data/test.old/slave.rb +21 -0
- metadata +19 -7
- data/sample/b.rb +0 -8
- data/sample/c.rb +0 -109
@@ -0,0 +1,117 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: @object</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<h1>@object <sup class="type-note">(Class)</sup></h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>In:</strong></td>
|
54
|
+
<td>
|
55
|
+
<a href="../files/lib/slave_rb.html">
|
56
|
+
lib/slave.rb
|
57
|
+
</a>
|
58
|
+
<br />
|
59
|
+
</td>
|
60
|
+
</tr>
|
61
|
+
|
62
|
+
</table>
|
63
|
+
</div>
|
64
|
+
<!-- banner header -->
|
65
|
+
|
66
|
+
<div id="bodyContent">
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
<div id="diagram">
|
71
|
+
<map name="map">
|
72
|
+
<area shape="RECT" coords="123,98,195,50" href=".././classes" alt="@object.html @object">
|
73
|
+
<area shape="RECT" coords="27,98,99,50" href="Slave.html" alt="Slave">
|
74
|
+
</map>
|
75
|
+
<img src="../dot/f_1.jpg" usemap="#map" border=0 alt="TopLevel">
|
76
|
+
</div>
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
<div id="attribute-list">
|
85
|
+
<h2 class="section-bar">Attributes</h2>
|
86
|
+
|
87
|
+
<div class="name-list">
|
88
|
+
<table>
|
89
|
+
<tr class="top-aligned-row context-row">
|
90
|
+
<td class="context-item-name">__slave_object_failure__</td>
|
91
|
+
<td class="context-item-value"> [RW] </td>
|
92
|
+
<td class="context-item-desc"></td>
|
93
|
+
</tr>
|
94
|
+
</table>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<!-- if includes -->
|
104
|
+
|
105
|
+
|
106
|
+
<!-- if method_list -->
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
<div id="validator-badges">
|
113
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
</body>
|
117
|
+
</html>
|
data/doc/classes/Slave.html
CHANGED
@@ -75,7 +75,8 @@
|
|
75
75
|
<div id="contextContent">
|
76
76
|
<div id="diagram">
|
77
77
|
<map name="map">
|
78
|
-
<area shape="RECT" coords="
|
78
|
+
<area shape="RECT" coords="123,98,195,50" href="o.html" alt="o">
|
79
|
+
<area shape="RECT" coords="27,98,99,50" href="Slave.html" alt="Slave">
|
79
80
|
</map>
|
80
81
|
<img src="../dot/f_1.jpg" usemap="#map" border=0 alt="TopLevel">
|
81
82
|
</div>
|
@@ -100,11 +101,27 @@ multi-threaded one. eg
|
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
|
-
slave = Slave.new Server.new
|
104
|
+
slave = Slave.new 'object' => Server.new
|
104
105
|
server = slave.object
|
105
106
|
|
106
107
|
p server.add_two(40) #=> 42
|
107
108
|
</pre>
|
109
|
+
<p>
|
110
|
+
two other methods of providing server objects exist:
|
111
|
+
</p>
|
112
|
+
<p>
|
113
|
+
a) server = Server.new "this is called the parent" }
|
114
|
+
</p>
|
115
|
+
<pre>
|
116
|
+
Slave.new(:object=>server){|s| puts "#{ s.inspect } passed to block in child process"}
|
117
|
+
</pre>
|
118
|
+
<p>
|
119
|
+
b) <a href="Slave.html#M000005">Slave.new</a>{ Server.new "this is
|
120
|
+
called only in the child" }
|
121
|
+
</p>
|
122
|
+
<p>
|
123
|
+
of the two ‘b’ is preferred.
|
124
|
+
</p>
|
108
125
|
|
109
126
|
</div>
|
110
127
|
|
@@ -113,16 +130,20 @@ multi-threaded one. eg
|
|
113
130
|
<h2 class="section-bar">Methods</h2>
|
114
131
|
|
115
132
|
<div class="name-list">
|
116
|
-
<a href="#
|
117
|
-
<a href="#M000002">
|
118
|
-
<a href="#
|
119
|
-
<a href="#
|
120
|
-
<a href="#
|
121
|
-
<a href="#M000003">
|
122
|
-
<a href="#
|
123
|
-
<a href="#
|
124
|
-
<a href="#
|
125
|
-
<a href="#
|
133
|
+
<a href="#M000012">default</a>
|
134
|
+
<a href="#M000002">default</a>
|
135
|
+
<a href="#M000006">detach</a>
|
136
|
+
<a href="#M000004">fork</a>
|
137
|
+
<a href="#M000011">gen_psname</a>
|
138
|
+
<a href="#M000003">getopts</a>
|
139
|
+
<a href="#M000013">getopts</a>
|
140
|
+
<a href="#M000005">new</a>
|
141
|
+
<a href="#M000009">shutdown</a>
|
142
|
+
<a href="#M000010">shutdown?</a>
|
143
|
+
<a href="#M000014">trace</a>
|
144
|
+
<a href="#M000001">version</a>
|
145
|
+
<a href="#M000007">wait</a>
|
146
|
+
<a href="#M000008">wait2</a>
|
126
147
|
</div>
|
127
148
|
</div>
|
128
149
|
|
@@ -134,7 +155,7 @@ multi-threaded one. eg
|
|
134
155
|
<tr class="top-aligned-row context-row">
|
135
156
|
<td class="context-item-name">VERSION</td>
|
136
157
|
<td>=</td>
|
137
|
-
<td class="context-item-value">'0.0
|
158
|
+
<td class="context-item-value">'1.0.0'</td>
|
138
159
|
</tr>
|
139
160
|
<tr class="top-aligned-row context-row">
|
140
161
|
<td class="context-item-name">DEFAULT_SOCKET_CREATION_ATTEMPTS</td>
|
@@ -170,7 +191,7 @@ config
|
|
170
191
|
<div class="name-list">
|
171
192
|
<table>
|
172
193
|
<tr class="top-aligned-row context-row">
|
173
|
-
<td class="context-item-name">
|
194
|
+
<td class="context-item-name">at_exit</td>
|
174
195
|
<td class="context-item-value"> [R] </td>
|
175
196
|
<td class="context-item-desc"></td>
|
176
197
|
</tr>
|
@@ -183,6 +204,11 @@ on STDERR
|
|
183
204
|
|
184
205
|
</td>
|
185
206
|
</tr>
|
207
|
+
<tr class="top-aligned-row context-row">
|
208
|
+
<td class="context-item-name">debug</td>
|
209
|
+
<td class="context-item-value"> [R] </td>
|
210
|
+
<td class="context-item-desc"></td>
|
211
|
+
</tr>
|
186
212
|
<tr class="top-aligned-row context-row">
|
187
213
|
<td class="context-item-name">obj</td>
|
188
214
|
<td class="context-item-value"> [R] </td>
|
@@ -222,6 +248,11 @@ href="Slave/Heartbeat.html">Heartbeat</a> object
|
|
222
248
|
<td class="context-item-value"> [R] </td>
|
223
249
|
<td class="context-item-desc"></td>
|
224
250
|
</tr>
|
251
|
+
<tr class="top-aligned-row context-row">
|
252
|
+
<td class="context-item-name">shutdown</td>
|
253
|
+
<td class="context-item-value"> [R] </td>
|
254
|
+
<td class="context-item-desc"></td>
|
255
|
+
</tr>
|
225
256
|
<tr class="top-aligned-row context-row">
|
226
257
|
<td class="context-item-name">socket</td>
|
227
258
|
<td class="context-item-value"> [R] </td>
|
@@ -232,6 +263,11 @@ href="Slave/Heartbeat.html">Heartbeat</a> object
|
|
232
263
|
<td class="context-item-value"> [RW] </td>
|
233
264
|
<td class="context-item-desc"></td>
|
234
265
|
</tr>
|
266
|
+
<tr class="top-aligned-row context-row">
|
267
|
+
<td class="context-item-name">socket_creation_attempts</td>
|
268
|
+
<td class="context-item-value"> [R] </td>
|
269
|
+
<td class="context-item-desc"></td>
|
270
|
+
</tr>
|
235
271
|
<tr class="top-aligned-row context-row">
|
236
272
|
<td class="context-item-name">status</td>
|
237
273
|
<td class="context-item-value"> [R] </td>
|
@@ -269,60 +305,58 @@ href="Slave/Heartbeat.html">Heartbeat</a> object
|
|
269
305
|
|
270
306
|
<div class="method-heading">
|
271
307
|
<a href="#M000002" class="method-signature">
|
272
|
-
<span class="method-name">
|
308
|
+
<span class="method-name">default</span><span class="method-args">key</span>
|
273
309
|
</a>
|
274
310
|
</div>
|
275
311
|
|
276
312
|
<div class="method-description">
|
277
313
|
<p>
|
278
|
-
|
314
|
+
get a default value
|
279
315
|
</p>
|
280
316
|
<p><a class="source-toggle" href="#"
|
281
317
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
282
318
|
<div class="method-source-code" id="M000002-source">
|
283
319
|
<pre>
|
284
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
76: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">fork</span> <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>
|
291
|
-
77: <span class="ruby-keyword kw">ensure</span>
|
292
|
-
78: <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">v</span>
|
293
|
-
79: <span class="ruby-keyword kw">end</span>
|
294
|
-
80: <span class="ruby-comment cmt">#--}}}</span>
|
295
|
-
81: <span class="ruby-keyword kw">end</span>
|
320
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 73</span>
|
321
|
+
73: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span> <span class="ruby-identifier">key</span>
|
322
|
+
74: <span class="ruby-comment cmt">#--{{{</span>
|
323
|
+
75: <span class="ruby-identifier">send</span> <span class="ruby-identifier">key</span>
|
324
|
+
76: <span class="ruby-comment cmt">#--}}}</span>
|
325
|
+
77: <span class="ruby-keyword kw">end</span>
|
296
326
|
</pre>
|
297
327
|
</div>
|
298
328
|
</div>
|
299
329
|
</div>
|
300
330
|
|
301
|
-
<div id="method-
|
302
|
-
<a name="
|
331
|
+
<div id="method-M000004" class="method-detail">
|
332
|
+
<a name="M000004"></a>
|
303
333
|
|
304
334
|
<div class="method-heading">
|
305
|
-
<a href="#
|
306
|
-
<span class="method-name">
|
335
|
+
<a href="#M000004" class="method-signature">
|
336
|
+
<span class="method-name">fork</span><span class="method-args">(&block)</span>
|
307
337
|
</a>
|
308
338
|
</div>
|
309
339
|
|
310
340
|
<div class="method-description">
|
311
341
|
<p>
|
312
|
-
|
342
|
+
just fork with out silly warnings
|
313
343
|
</p>
|
314
344
|
<p><a class="source-toggle" href="#"
|
315
|
-
onclick="toggleCode('
|
316
|
-
<div class="method-source-code" id="
|
345
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
346
|
+
<div class="method-source-code" id="M000004-source">
|
317
347
|
<pre>
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
348
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 94</span>
|
349
|
+
94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fork</span> <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>
|
350
|
+
95: <span class="ruby-comment cmt">#--{{{</span>
|
351
|
+
96: <span class="ruby-identifier">v</span> = <span class="ruby-identifier">$VERBOSE</span>
|
352
|
+
97: <span class="ruby-keyword kw">begin</span>
|
353
|
+
98: <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-keyword kw">nil</span>
|
354
|
+
99: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">fork</span> <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>
|
355
|
+
100: <span class="ruby-keyword kw">ensure</span>
|
356
|
+
101: <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">v</span>
|
357
|
+
102: <span class="ruby-keyword kw">end</span>
|
358
|
+
103: <span class="ruby-comment cmt">#--}}}</span>
|
359
|
+
104: <span class="ruby-keyword kw">end</span>
|
326
360
|
</pre>
|
327
361
|
</div>
|
328
362
|
</div>
|
@@ -333,120 +367,233 @@ look up a value in an option hash failing back to class defaults
|
|
333
367
|
|
334
368
|
<div class="method-heading">
|
335
369
|
<a href="#M000003" class="method-signature">
|
336
|
-
<span class="method-name">
|
370
|
+
<span class="method-name">getopts</span><span class="method-args">opts</span>
|
337
371
|
</a>
|
338
372
|
</div>
|
339
373
|
|
340
374
|
<div class="method-description">
|
341
|
-
<p>
|
342
|
-
‘obj’ can be any object and ‘opts’ may contain the
|
343
|
-
keys ‘socket_creation_attempts’, ‘pulse_rate’,
|
344
|
-
‘psname’, or ‘debug’
|
345
|
-
</p>
|
346
375
|
<p><a class="source-toggle" href="#"
|
347
376
|
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
348
377
|
<div class="method-source-code" id="M000003-source">
|
349
378
|
<pre>
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
379
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 79</span>
|
380
|
+
79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getopts</span> <span class="ruby-identifier">opts</span>
|
381
|
+
80: <span class="ruby-comment cmt">#--{{{</span>
|
382
|
+
81: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">class</span> <span class="ruby-keyword kw">unless</span>
|
383
|
+
82: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">'has_key?'</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">'[]'</span>)
|
384
|
+
83:
|
385
|
+
84: <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">defval</span><span class="ruby-operator">|</span>
|
386
|
+
85: <span class="ruby-identifier">defval</span> = <span class="ruby-identifier">defval</span>.<span class="ruby-identifier">shift</span>
|
387
|
+
86: <span class="ruby-identifier">keys</span> = [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">intern</span>]
|
388
|
+
87: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">detect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">k</span> } <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">break</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">key</span>]
|
389
|
+
88: <span class="ruby-identifier">defval</span>
|
390
|
+
89: <span class="ruby-keyword kw">end</span>
|
391
|
+
90: <span class="ruby-comment cmt">#--}}}</span>
|
392
|
+
91: <span class="ruby-keyword kw">end</span>
|
393
|
+
</pre>
|
394
|
+
</div>
|
395
|
+
</div>
|
396
|
+
</div>
|
397
|
+
|
398
|
+
<div id="method-M000005" class="method-detail">
|
399
|
+
<a name="M000005"></a>
|
400
|
+
|
401
|
+
<div class="method-heading">
|
402
|
+
<a href="#M000005" class="method-signature">
|
403
|
+
<span class="method-name">new</span><span class="method-args">opts = {}, &block</span>
|
404
|
+
</a>
|
405
|
+
</div>
|
406
|
+
|
407
|
+
<div class="method-description">
|
408
|
+
<p>
|
409
|
+
opts may contain the keys ‘object’,
|
410
|
+
‘socket_creation_attempts’, ‘pulse_rate’,
|
411
|
+
‘psname’, ‘dumped’, or ‘debug’
|
412
|
+
</p>
|
413
|
+
<p><a class="source-toggle" href="#"
|
414
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
415
|
+
<div class="method-source-code" id="M000005-source">
|
416
|
+
<pre>
|
417
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 128</span>
|
418
|
+
128: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>
|
419
|
+
129: <span class="ruby-comment cmt">#--{{{</span>
|
420
|
+
130: <span class="ruby-identifier">getopt</span> = <span class="ruby-identifier">getopts</span> <span class="ruby-identifier">opts</span>
|
382
421
|
131:
|
383
|
-
132:
|
384
|
-
133:
|
385
|
-
134:
|
386
|
-
135:
|
387
|
-
136:
|
388
|
-
137:
|
389
|
-
138:
|
390
|
-
139:
|
391
|
-
140:
|
392
|
-
141:
|
393
|
-
142:
|
394
|
-
143:
|
395
|
-
144:
|
396
|
-
145:
|
397
|
-
146:
|
398
|
-
147:
|
399
|
-
148:
|
422
|
+
132: <span class="ruby-ivar">@obj</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'object'</span>]
|
423
|
+
133: <span class="ruby-ivar">@socket_creation_attempts</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'socket_creation_attempts'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>(<span class="ruby-value str">'socket_creation_attempts'</span>)
|
424
|
+
134: <span class="ruby-ivar">@pulse_rate</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'pulse_rate'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>(<span class="ruby-value str">'pulse_rate'</span>)
|
425
|
+
135: <span class="ruby-ivar">@debug</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'debug'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>(<span class="ruby-value str">'debug'</span>)
|
426
|
+
136: <span class="ruby-ivar">@psname</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'psname'</span>]
|
427
|
+
137: <span class="ruby-ivar">@at_exit</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'at_exit'</span>]
|
428
|
+
138: <span class="ruby-ivar">@dumped</span> = <span class="ruby-identifier">getopt</span>[<span class="ruby-value str">'dumped'</span>]
|
429
|
+
139:
|
430
|
+
140: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'no slave object!'</span> <span class="ruby-keyword kw">if</span>
|
431
|
+
141: <span class="ruby-ivar">@obj</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">nil?</span>
|
432
|
+
142:
|
433
|
+
143: <span class="ruby-ivar">@shutdown</span> = <span class="ruby-keyword kw">false</span>
|
434
|
+
144: <span class="ruby-ivar">@waiter</span> = <span class="ruby-ivar">@status</span> = <span class="ruby-keyword kw">nil</span>
|
435
|
+
145:
|
436
|
+
146: <span class="ruby-ivar">@heartbeat</span> = <span class="ruby-constant">Heartbeat</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span> <span class="ruby-ivar">@pulse_rate</span>, <span class="ruby-ivar">@debug</span>
|
437
|
+
147: <span class="ruby-ivar">@r</span>, <span class="ruby-ivar">@w</span> = <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-identifier">pipe</span>
|
438
|
+
148: <span class="ruby-ivar">@r2</span>, <span class="ruby-ivar">@w2</span> = <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-identifier">pipe</span>
|
400
439
|
149:
|
401
|
-
150:
|
402
|
-
151:
|
403
|
-
152:
|
404
|
-
153:
|
405
|
-
154:
|
406
|
-
155:
|
407
|
-
156:
|
408
|
-
157:
|
409
|
-
158:
|
410
|
-
159:
|
411
|
-
160:
|
412
|
-
161:
|
413
|
-
162:
|
414
|
-
163:
|
415
|
-
164:
|
416
|
-
165: <span class="ruby-keyword kw">
|
417
|
-
166: <span class="ruby-identifier">
|
418
|
-
167:
|
419
|
-
168: <span class="ruby-
|
420
|
-
169:
|
421
|
-
170:
|
422
|
-
171:
|
423
|
-
172:
|
424
|
-
173:
|
425
|
-
174:
|
426
|
-
175:
|
427
|
-
176:
|
428
|
-
177:
|
429
|
-
178:
|
430
|
-
179:
|
431
|
-
180:
|
432
|
-
181:
|
433
|
-
182:
|
434
|
-
183:
|
435
|
-
184: <span class="ruby-
|
436
|
-
185:
|
437
|
-
186: <span class="ruby-identifier"
|
438
|
-
187: <span class="ruby-ivar">@
|
439
|
-
188:
|
440
|
-
189:
|
441
|
-
190:
|
442
|
-
191: <span class="ruby-
|
443
|
-
192:
|
444
|
-
193:
|
445
|
-
194: <span class="ruby-
|
446
|
-
195:
|
447
|
-
196:
|
448
|
-
197:
|
449
|
-
198:
|
440
|
+
150: <span class="ruby-comment cmt"># weird syntax because dot/rdoc chokes on this!?!?</span>
|
441
|
+
151: <span class="ruby-identifier">init_failure</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
442
|
+
152: <span class="ruby-identifier">o</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
443
|
+
153: <span class="ruby-keyword kw">class</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">o</span>
|
444
|
+
154: <span class="ruby-identifier">attr_accessor</span> <span class="ruby-value str">'__slave_object_failure__'</span>
|
445
|
+
155: <span class="ruby-keyword kw">end</span>
|
446
|
+
156: <span class="ruby-identifier">o</span>.<span class="ruby-identifier">__slave_object_failure__</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span> [<span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>]
|
447
|
+
157: <span class="ruby-ivar">@object</span> = <span class="ruby-identifier">o</span>
|
448
|
+
158: <span class="ruby-keyword kw">end</span>
|
449
|
+
159:
|
450
|
+
160: <span class="ruby-comment cmt">#</span>
|
451
|
+
161: <span class="ruby-comment cmt"># child</span>
|
452
|
+
162: <span class="ruby-comment cmt">#</span>
|
453
|
+
163: <span class="ruby-keyword kw">unless</span>((<span class="ruby-ivar">@pid</span> = <span class="ruby-constant">Slave</span><span class="ruby-operator">::</span><span class="ruby-identifier">fork</span>))
|
454
|
+
164: <span class="ruby-identifier">e</span> = <span class="ruby-keyword kw">nil</span>
|
455
|
+
165: <span class="ruby-keyword kw">begin</span>
|
456
|
+
166: <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">at_exit</span>{ <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">exit!</span> }
|
457
|
+
167:
|
458
|
+
168: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@obj</span>
|
459
|
+
169: <span class="ruby-ivar">@object</span> = <span class="ruby-ivar">@obj</span>
|
460
|
+
170: <span class="ruby-keyword kw">else</span>
|
461
|
+
171: <span class="ruby-keyword kw">begin</span>
|
462
|
+
172: <span class="ruby-ivar">@object</span> = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>
|
463
|
+
173: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
464
|
+
174: <span class="ruby-identifier">init_failure</span>[<span class="ruby-identifier">e</span>]
|
465
|
+
175: <span class="ruby-keyword kw">end</span>
|
466
|
+
176: <span class="ruby-keyword kw">end</span>
|
467
|
+
177:
|
468
|
+
178: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@obj</span>
|
469
|
+
179: <span class="ruby-keyword kw">begin</span>
|
470
|
+
180: <span class="ruby-identifier">block</span>[<span class="ruby-ivar">@obj</span>]
|
471
|
+
181: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
472
|
+
182: <span class="ruby-identifier">init_failure</span>[<span class="ruby-identifier">e</span>]
|
473
|
+
183: <span class="ruby-keyword kw">end</span>
|
474
|
+
184: <span class="ruby-keyword kw">end</span>
|
475
|
+
185:
|
476
|
+
186: <span class="ruby-identifier">$0</span> = (<span class="ruby-ivar">@psname</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">gen_psname</span>(<span class="ruby-ivar">@object</span>))
|
477
|
+
187: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@dumped</span> <span class="ruby-keyword kw">or</span> <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">'__slave_object_failure__'</span>)
|
478
|
+
188: <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">DRbUndumped</span>
|
479
|
+
189: <span class="ruby-keyword kw">end</span>
|
480
|
+
190:
|
481
|
+
191: <span class="ruby-ivar">@ppid</span>, <span class="ruby-ivar">@pid</span> = <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">ppid</span>, <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">pid</span>
|
482
|
+
192:
|
483
|
+
193: <span class="ruby-ivar">@r</span>.<span class="ruby-identifier">close</span>
|
484
|
+
194: <span class="ruby-ivar">@r2</span>.<span class="ruby-identifier">close</span>
|
485
|
+
195: <span class="ruby-ivar">@socket</span> = <span class="ruby-keyword kw">nil</span>
|
486
|
+
196: <span class="ruby-ivar">@uri</span> = <span class="ruby-keyword kw">nil</span>
|
487
|
+
197:
|
488
|
+
198: <span class="ruby-identifier">tmpdir</span>, <span class="ruby-identifier">basename</span> = <span class="ruby-constant">Dir</span><span class="ruby-operator">::</span><span class="ruby-identifier">tmpdir</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">basename</span>(<span class="ruby-ivar">@psname</span>)
|
489
|
+
199:
|
490
|
+
200: <span class="ruby-ivar">@socket_creation_attempts</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attempt</span><span class="ruby-operator">|</span>
|
491
|
+
201: <span class="ruby-identifier">se</span> = <span class="ruby-keyword kw">nil</span>
|
492
|
+
202: <span class="ruby-keyword kw">begin</span>
|
493
|
+
203: <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">join</span>(<span class="ruby-identifier">tmpdir</span>, <span class="ruby-node">"#{ basename }_#{ attempt }"</span>)
|
494
|
+
204: <span class="ruby-identifier">u</span> = <span class="ruby-node">"drbunix://#{ s }"</span>
|
495
|
+
205: <span class="ruby-constant">DRb</span><span class="ruby-operator">::</span><span class="ruby-identifier">start_service</span> <span class="ruby-identifier">u</span>, <span class="ruby-ivar">@object</span>
|
496
|
+
206: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">s</span>
|
497
|
+
207: <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">u</span>
|
498
|
+
208: <span class="ruby-identifier">trace</span>{ <span class="ruby-node">"child - socket <#{ @socket }>"</span> }
|
499
|
+
209: <span class="ruby-identifier">trace</span>{ <span class="ruby-node">"child - uri <#{ @uri }>"</span> }
|
500
|
+
210: <span class="ruby-keyword kw">break</span>
|
501
|
+
211: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EADDRINUSE</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">se</span>
|
502
|
+
212: <span class="ruby-keyword kw">nil</span>
|
503
|
+
213: <span class="ruby-keyword kw">end</span>
|
504
|
+
214: <span class="ruby-keyword kw">end</span>
|
505
|
+
215:
|
506
|
+
216: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@socket</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@uri</span>
|
507
|
+
217: <span class="ruby-ivar">@heartbeat</span>.<span class="ruby-identifier">start</span>
|
508
|
+
218:
|
509
|
+
219: <span class="ruby-identifier">trap</span>(<span class="ruby-value str">'SIGUSR2'</span>) <span class="ruby-keyword kw">do</span>
|
510
|
+
220: <span class="ruby-comment cmt"># @heartbeat.stop rescue nil</span>
|
511
|
+
221: <span class="ruby-constant">DBb</span><span class="ruby-operator">::</span><span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
512
|
+
222: <span class="ruby-constant">FileUtils</span><span class="ruby-operator">::</span><span class="ruby-identifier">rm_f</span> <span class="ruby-ivar">@socket</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
513
|
+
223: <span class="ruby-identifier">exit</span>
|
514
|
+
224: <span class="ruby-keyword kw">end</span>
|
515
|
+
225:
|
516
|
+
226: <span class="ruby-ivar">@w</span>.<span class="ruby-identifier">write</span> <span class="ruby-ivar">@socket</span>
|
517
|
+
227: <span class="ruby-ivar">@w</span>.<span class="ruby-identifier">close</span>
|
518
|
+
228: <span class="ruby-constant">DRb</span><span class="ruby-operator">::</span><span class="ruby-identifier">thread</span>.<span class="ruby-identifier">join</span>
|
519
|
+
229: <span class="ruby-keyword kw">else</span>
|
520
|
+
230: <span class="ruby-ivar">@w</span>.<span class="ruby-identifier">close</span>
|
521
|
+
231: <span class="ruby-keyword kw">end</span>
|
522
|
+
232: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
523
|
+
233: <span class="ruby-identifier">trace</span>{ <span class="ruby-node">%[#{ e.message } (#{ e.class })\n#{ e.backtrace.join "\n" }]</span> }
|
524
|
+
234: <span class="ruby-keyword kw">ensure</span>
|
525
|
+
235: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">'status'</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>
|
526
|
+
236: <span class="ruby-identifier">exit</span>(<span class="ruby-identifier">status</span>)
|
527
|
+
237: <span class="ruby-keyword kw">end</span>
|
528
|
+
238: <span class="ruby-comment cmt">#</span>
|
529
|
+
239: <span class="ruby-comment cmt"># parent </span>
|
530
|
+
240: <span class="ruby-comment cmt">#</span>
|
531
|
+
241: <span class="ruby-keyword kw">else</span>
|
532
|
+
242: <span class="ruby-identifier">detach</span>
|
533
|
+
243: <span class="ruby-ivar">@w</span>.<span class="ruby-identifier">close</span>
|
534
|
+
244: <span class="ruby-ivar">@w2</span>.<span class="ruby-identifier">close</span>
|
535
|
+
245: <span class="ruby-ivar">@socket</span> = <span class="ruby-ivar">@r</span>.<span class="ruby-identifier">read</span>
|
536
|
+
246: <span class="ruby-ivar">@r</span>.<span class="ruby-identifier">close</span>
|
537
|
+
247:
|
538
|
+
248: <span class="ruby-identifier">trace</span>{ <span class="ruby-node">"parent - socket <#{ @socket }>"</span> }
|
539
|
+
249:
|
540
|
+
250: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@at_exit</span>
|
541
|
+
251: <span class="ruby-ivar">@at_exit_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>{
|
542
|
+
252: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">abort_on_exception</span> = <span class="ruby-keyword kw">true</span>
|
543
|
+
253:
|
544
|
+
254: <span class="ruby-ivar">@r2</span>.<span class="ruby-identifier">read</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-value">42</span>
|
545
|
+
255:
|
546
|
+
256: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@at_exit</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value str">'call'</span>
|
547
|
+
257: <span class="ruby-ivar">@at_exit</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">self</span>
|
548
|
+
258: <span class="ruby-keyword kw">else</span>
|
549
|
+
259: <span class="ruby-identifier">send</span> <span class="ruby-ivar">@at_exit</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">self</span>
|
550
|
+
260: <span class="ruby-keyword kw">end</span>
|
551
|
+
261: }
|
552
|
+
262: <span class="ruby-keyword kw">end</span>
|
553
|
+
263:
|
554
|
+
264: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@socket</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">exist?</span> <span class="ruby-ivar">@socket</span>
|
555
|
+
265: <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">at_exit</span>{ <span class="ruby-constant">FileUtils</span><span class="ruby-operator">::</span><span class="ruby-identifier">rm_f</span> <span class="ruby-ivar">@socket</span> }
|
556
|
+
266: <span class="ruby-ivar">@uri</span> = <span class="ruby-node">"drbunix://#{ socket }"</span>
|
557
|
+
267: <span class="ruby-identifier">trace</span>{ <span class="ruby-node">"parent - uri <#{ @uri }>"</span> }
|
558
|
+
268: <span class="ruby-ivar">@heartbeat</span>.<span class="ruby-identifier">start</span>
|
559
|
+
269: <span class="ruby-comment cmt">#</span>
|
560
|
+
270: <span class="ruby-comment cmt"># starting drb on localhost avoids dns lookups!</span>
|
561
|
+
271: <span class="ruby-comment cmt">#</span>
|
562
|
+
272: <span class="ruby-constant">DRb</span><span class="ruby-operator">::</span><span class="ruby-identifier">start_service</span>(<span class="ruby-value str">'druby://localhost:0'</span>, <span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">DRb</span><span class="ruby-operator">::</span><span class="ruby-identifier">thread</span>
|
563
|
+
273: <span class="ruby-ivar">@object</span> = <span class="ruby-constant">DRbObject</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@uri</span>
|
564
|
+
274: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value str">'__slave_object_failure__'</span>
|
565
|
+
275: <span class="ruby-identifier">c</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">bt</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span> <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">__slave_object_failure__</span>
|
566
|
+
276: (<span class="ruby-identifier">e</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>)).<span class="ruby-identifier">set_backtrace</span> <span class="ruby-identifier">bt</span>
|
567
|
+
277: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
568
|
+
278: <span class="ruby-keyword kw">end</span>
|
569
|
+
279: <span class="ruby-ivar">@psname</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">gen_psname</span>(<span class="ruby-ivar">@object</span>)
|
570
|
+
280: <span class="ruby-keyword kw">else</span>
|
571
|
+
281: <span class="ruby-identifier">raise</span> <span class="ruby-node">"failed to find slave socket <#{ @socket }>"</span>
|
572
|
+
282: <span class="ruby-keyword kw">end</span>
|
573
|
+
283: <span class="ruby-keyword kw">end</span>
|
574
|
+
284: <span class="ruby-comment cmt">#--}}}</span>
|
575
|
+
285: <span class="ruby-keyword kw">end</span>
|
576
|
+
</pre>
|
577
|
+
</div>
|
578
|
+
</div>
|
579
|
+
</div>
|
580
|
+
|
581
|
+
<div id="method-M000001" class="method-detail">
|
582
|
+
<a name="M000001"></a>
|
583
|
+
|
584
|
+
<div class="method-heading">
|
585
|
+
<a href="#M000001" class="method-signature">
|
586
|
+
<span class="method-name">version</span><span class="method-args">()</span>
|
587
|
+
</a>
|
588
|
+
</div>
|
589
|
+
|
590
|
+
<div class="method-description">
|
591
|
+
<p><a class="source-toggle" href="#"
|
592
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
593
|
+
<div class="method-source-code" id="M000001-source">
|
594
|
+
<pre>
|
595
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 40</span>
|
596
|
+
40: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">version</span>() <span class="ruby-constant">VERSION</span> <span class="ruby-keyword kw">end</span>
|
450
597
|
</pre>
|
451
598
|
</div>
|
452
599
|
</div>
|
@@ -454,40 +601,90 @@ keys ‘socket_creation_attempts’, ‘pulse_rate’,
|
|
454
601
|
|
455
602
|
<h2 class="section-bar">Public Instance methods</h2>
|
456
603
|
|
457
|
-
<div id="method-
|
458
|
-
<a name="
|
604
|
+
<div id="method-M000012" class="method-detail">
|
605
|
+
<a name="M000012"></a>
|
459
606
|
|
460
607
|
<div class="method-heading">
|
461
|
-
<a href="#
|
608
|
+
<a href="#M000012" class="method-signature">
|
609
|
+
<span class="method-name">default</span><span class="method-args">key</span>
|
610
|
+
</a>
|
611
|
+
</div>
|
612
|
+
|
613
|
+
<div class="method-description">
|
614
|
+
<p>
|
615
|
+
see docs for <a href="Slave.html#M000002">Slave.default</a>
|
616
|
+
</p>
|
617
|
+
<p><a class="source-toggle" href="#"
|
618
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
619
|
+
<div class="method-source-code" id="M000012-source">
|
620
|
+
<pre>
|
621
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 364</span>
|
622
|
+
364: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span> <span class="ruby-identifier">key</span>
|
623
|
+
365: <span class="ruby-comment cmt">#--{{{</span>
|
624
|
+
366: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">default</span> <span class="ruby-identifier">key</span>
|
625
|
+
367: <span class="ruby-comment cmt">#--}}}</span>
|
626
|
+
368: <span class="ruby-keyword kw">end</span>
|
627
|
+
</pre>
|
628
|
+
</div>
|
629
|
+
</div>
|
630
|
+
</div>
|
631
|
+
|
632
|
+
<div id="method-M000006" class="method-detail">
|
633
|
+
<a name="M000006"></a>
|
634
|
+
|
635
|
+
<div class="method-heading">
|
636
|
+
<a href="#M000006" class="method-signature">
|
462
637
|
<span class="method-name">detach</span><span class="method-args">()</span>
|
463
638
|
</a>
|
464
639
|
</div>
|
465
640
|
|
466
641
|
<div class="method-description">
|
467
642
|
<p>
|
468
|
-
starts a thread to
|
643
|
+
starts a thread to collect the child status and sets up at_exit handler to
|
644
|
+
prevent zombies. the at_exit handler is canceled if the thread is able to
|
645
|
+
collect the status
|
469
646
|
</p>
|
470
647
|
<p><a class="source-toggle" href="#"
|
471
|
-
onclick="toggleCode('
|
472
|
-
<div class="method-source-code" id="
|
648
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
649
|
+
<div class="method-source-code" id="M000006-source">
|
473
650
|
<pre>
|
474
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
651
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 291</span>
|
652
|
+
291: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">detach</span>
|
653
|
+
292: <span class="ruby-comment cmt">#--{{{</span>
|
654
|
+
293: <span class="ruby-identifier">reap</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cid</span><span class="ruby-operator">|</span>
|
655
|
+
294: <span class="ruby-keyword kw">begin</span>
|
656
|
+
295: <span class="ruby-ivar">@status</span> = <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">cid</span>).<span class="ruby-identifier">last</span>
|
657
|
+
296: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
658
|
+
297: <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span>, <span class="ruby-identifier">b</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
659
|
+
298: <span class="ruby-identifier">warn</span> <span class="ruby-node">"#{ m } (#{ c })\n#{ b }"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECHILD</span>
|
660
|
+
299: <span class="ruby-keyword kw">end</span>
|
661
|
+
300: <span class="ruby-keyword kw">end</span>
|
662
|
+
301:
|
663
|
+
302: <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">at_exit</span> <span class="ruby-keyword kw">do</span>
|
664
|
+
303: <span class="ruby-identifier">shutdown</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
665
|
+
304: <span class="ruby-identifier">reap</span>[<span class="ruby-ivar">@pid</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
666
|
+
305: <span class="ruby-keyword kw">end</span>
|
667
|
+
306:
|
668
|
+
307: <span class="ruby-ivar">@waiter</span> =
|
669
|
+
308: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
670
|
+
309: <span class="ruby-keyword kw">begin</span>
|
671
|
+
310: <span class="ruby-ivar">@status</span> = <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">waitpid2</span>(<span class="ruby-ivar">@pid</span>).<span class="ruby-identifier">last</span>
|
672
|
+
311: <span class="ruby-keyword kw">ensure</span>
|
673
|
+
312: <span class="ruby-identifier">reap</span> = <span class="ruby-identifier">lambda</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">cid</span><span class="ruby-operator">|</span> <span class="ruby-value str">'no-op'</span> }
|
674
|
+
313: <span class="ruby-keyword kw">end</span>
|
675
|
+
314: <span class="ruby-keyword kw">end</span>
|
676
|
+
315: <span class="ruby-comment cmt">#--}}}</span>
|
677
|
+
316: <span class="ruby-keyword kw">end</span>
|
481
678
|
</pre>
|
482
679
|
</div>
|
483
680
|
</div>
|
484
681
|
</div>
|
485
682
|
|
486
|
-
<div id="method-
|
487
|
-
<a name="
|
683
|
+
<div id="method-M000011" class="method-detail">
|
684
|
+
<a name="M000011"></a>
|
488
685
|
|
489
686
|
<div class="method-heading">
|
490
|
-
<a href="#
|
687
|
+
<a href="#M000011" class="method-signature">
|
491
688
|
<span class="method-name">gen_psname</span><span class="method-args">obj</span>
|
492
689
|
</a>
|
493
690
|
</div>
|
@@ -497,15 +694,43 @@ starts a thread to attempt collecting the child status
|
|
497
694
|
generate a default name to appear in ps/top
|
498
695
|
</p>
|
499
696
|
<p><a class="source-toggle" href="#"
|
500
|
-
onclick="toggleCode('
|
501
|
-
<div class="method-source-code" id="
|
697
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
698
|
+
<div class="method-source-code" id="M000011-source">
|
699
|
+
<pre>
|
700
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 356</span>
|
701
|
+
356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">gen_psname</span> <span class="ruby-identifier">obj</span>
|
702
|
+
357: <span class="ruby-comment cmt">#--{{{</span>
|
703
|
+
358: <span class="ruby-node">"#{ obj.class }_#{ obj.object_id }_#{ Process::ppid }_#{ Process::pid }"</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">%/\s+/</span>,<span class="ruby-value str">'_'</span>)
|
704
|
+
359: <span class="ruby-comment cmt">#--}}}</span>
|
705
|
+
360: <span class="ruby-keyword kw">end</span>
|
706
|
+
</pre>
|
707
|
+
</div>
|
708
|
+
</div>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
<div id="method-M000013" class="method-detail">
|
712
|
+
<a name="M000013"></a>
|
713
|
+
|
714
|
+
<div class="method-heading">
|
715
|
+
<a href="#M000013" class="method-signature">
|
716
|
+
<span class="method-name">getopts</span><span class="method-args">opts</span>
|
717
|
+
</a>
|
718
|
+
</div>
|
719
|
+
|
720
|
+
<div class="method-description">
|
721
|
+
<p>
|
722
|
+
see docs for <a href="Slave.html#M000003">Slave.getopts</a>
|
723
|
+
</p>
|
724
|
+
<p><a class="source-toggle" href="#"
|
725
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
726
|
+
<div class="method-source-code" id="M000013-source">
|
502
727
|
<pre>
|
503
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
728
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 372</span>
|
729
|
+
372: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getopts</span> <span class="ruby-identifier">opts</span>
|
730
|
+
373: <span class="ruby-comment cmt">#--{{{</span>
|
731
|
+
374: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">getopts</span> <span class="ruby-identifier">opts</span>
|
732
|
+
375: <span class="ruby-comment cmt">#--}}}</span>
|
733
|
+
376: <span class="ruby-keyword kw">end</span>
|
509
734
|
</pre>
|
510
735
|
</div>
|
511
736
|
</div>
|
@@ -516,67 +741,69 @@ generate a default name to appear in ps/top
|
|
516
741
|
|
517
742
|
<div class="method-heading">
|
518
743
|
<a href="#M000009" class="method-signature">
|
519
|
-
<span class="method-name">
|
744
|
+
<span class="method-name">shutdown</span><span class="method-args">opts = {}</span>
|
520
745
|
</a>
|
521
746
|
</div>
|
522
747
|
|
523
748
|
<div class="method-description">
|
524
749
|
<p>
|
525
|
-
|
750
|
+
stops the heartbeat thread and kills the child process - give the key
|
751
|
+
‘quiet’ to ignore errors shutting down, including having
|
752
|
+
already shutdown
|
526
753
|
</p>
|
527
754
|
<p><a class="source-toggle" href="#"
|
528
755
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
529
756
|
<div class="method-source-code" id="M000009-source">
|
530
757
|
<pre>
|
531
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
758
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 335</span>
|
759
|
+
335: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shutdown</span> <span class="ruby-identifier">opts</span> = {}
|
760
|
+
336: <span class="ruby-comment cmt">#--{{{</span>
|
761
|
+
337: <span class="ruby-identifier">quiet</span> = <span class="ruby-identifier">getopts</span>(<span class="ruby-identifier">opts</span>)[<span class="ruby-value str">'quiet'</span>]
|
762
|
+
338: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"already shutdown"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@shutdown</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">quiet</span>
|
763
|
+
339: <span class="ruby-identifier">failure</span> = <span class="ruby-identifier">lambda</span>{ <span class="ruby-identifier">raise</span> <span class="ruby-identifier">$!</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">quiet</span> }
|
764
|
+
340: <span class="ruby-ivar">@heartbeat</span>.<span class="ruby-identifier">stop</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">failure</span>.<span class="ruby-identifier">call</span>
|
765
|
+
341: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">kill</span>(<span class="ruby-value str">'SIGUSR2'</span>, <span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">failure</span>.<span class="ruby-identifier">call</span>
|
766
|
+
342: <span class="ruby-ivar">@shutdown</span> = <span class="ruby-keyword kw">true</span>
|
767
|
+
343: <span class="ruby-comment cmt">#--}}}</span>
|
768
|
+
344: <span class="ruby-keyword kw">end</span>
|
537
769
|
</pre>
|
538
770
|
</div>
|
539
771
|
</div>
|
540
772
|
</div>
|
541
773
|
|
542
|
-
<div id="method-
|
543
|
-
<a name="
|
774
|
+
<div id="method-M000010" class="method-detail">
|
775
|
+
<a name="M000010"></a>
|
544
776
|
|
545
777
|
<div class="method-heading">
|
546
|
-
<a href="#
|
547
|
-
<span class="method-name">shutdown
|
778
|
+
<a href="#M000010" class="method-signature">
|
779
|
+
<span class="method-name">shutdown?</span><span class="method-args">()</span>
|
548
780
|
</a>
|
549
781
|
</div>
|
550
782
|
|
551
783
|
<div class="method-description">
|
552
784
|
<p>
|
553
|
-
|
785
|
+
true
|
554
786
|
</p>
|
555
787
|
<p><a class="source-toggle" href="#"
|
556
|
-
onclick="toggleCode('
|
557
|
-
<div class="method-source-code" id="
|
788
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
789
|
+
<div class="method-source-code" id="M000010-source">
|
558
790
|
<pre>
|
559
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
225: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">kill</span>(<span class="ruby-value str">'SIGTERM'</span>, <span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
566
|
-
226: <span class="ruby-constant">FileUtils</span><span class="ruby-operator">::</span><span class="ruby-identifier">rm_f</span> <span class="ruby-ivar">@socket</span>
|
567
|
-
227: <span class="ruby-ivar">@shutdown</span> = <span class="ruby-keyword kw">true</span>
|
568
|
-
228: <span class="ruby-comment cmt">#--}}}</span>
|
569
|
-
229: <span class="ruby-keyword kw">end</span>
|
791
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 348</span>
|
792
|
+
348: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shutdown?</span>
|
793
|
+
349: <span class="ruby-comment cmt">#--{{{</span>
|
794
|
+
350: <span class="ruby-ivar">@shutdown</span>
|
795
|
+
351: <span class="ruby-comment cmt">#--}}}</span>
|
796
|
+
352: <span class="ruby-keyword kw">end</span>
|
570
797
|
</pre>
|
571
798
|
</div>
|
572
799
|
</div>
|
573
800
|
</div>
|
574
801
|
|
575
|
-
<div id="method-
|
576
|
-
<a name="
|
802
|
+
<div id="method-M000014" class="method-detail">
|
803
|
+
<a name="M000014"></a>
|
577
804
|
|
578
805
|
<div class="method-heading">
|
579
|
-
<a href="#
|
806
|
+
<a href="#M000014" class="method-signature">
|
580
807
|
<span class="method-name">trace</span><span class="method-args">() {|| ...}</span>
|
581
808
|
</a>
|
582
809
|
</div>
|
@@ -586,58 +813,64 @@ stops the heartbeat thread and kills the child process
|
|
586
813
|
debugging output - ENV[‘SLAVE_DEBUG’]=1 to enable
|
587
814
|
</p>
|
588
815
|
<p><a class="source-toggle" href="#"
|
589
|
-
onclick="toggleCode('
|
590
|
-
<div class="method-source-code" id="
|
816
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
817
|
+
<div class="method-source-code" id="M000014-source">
|
591
818
|
<pre>
|
592
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
819
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 380</span>
|
820
|
+
380: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">trace</span>
|
821
|
+
381: <span class="ruby-comment cmt">#--{{{</span>
|
822
|
+
382: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-keyword kw">yield</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@debug</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">tty?</span>
|
823
|
+
383: <span class="ruby-comment cmt">#--}}}</span>
|
824
|
+
384: <span class="ruby-keyword kw">end</span>
|
598
825
|
</pre>
|
599
826
|
</div>
|
600
827
|
</div>
|
601
828
|
</div>
|
602
829
|
|
603
|
-
<div id="method-
|
604
|
-
<a name="
|
830
|
+
<div id="method-M000007" class="method-detail">
|
831
|
+
<a name="M000007"></a>
|
605
832
|
|
606
833
|
<div class="method-heading">
|
607
|
-
<a href="#
|
608
|
-
<span class="method-name">wait</span><span class="method-args">
|
834
|
+
<a href="#M000007" class="method-signature">
|
835
|
+
<span class="method-name">wait</span><span class="method-args">opts = {}, &b</span>
|
609
836
|
</a>
|
610
837
|
</div>
|
611
838
|
|
612
839
|
<div class="method-description">
|
613
840
|
<p>
|
614
|
-
wait for slave to finish
|
841
|
+
wait for slave to finish. if the keyword ‘non_block’=>true
|
842
|
+
is given a thread is returned to do the waiting in an async fashion. eg
|
615
843
|
</p>
|
844
|
+
<pre>
|
845
|
+
thread = slave.wait(:non_block=>true){|value| "background <#{ value }>"}
|
846
|
+
</pre>
|
616
847
|
<p><a class="source-toggle" href="#"
|
617
|
-
onclick="toggleCode('
|
618
|
-
<div class="method-source-code" id="
|
848
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
849
|
+
<div class="method-source-code" id="M000007-source">
|
619
850
|
<pre>
|
620
|
-
<span class="ruby-comment cmt"># File lib/slave.rb, line
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
851
|
+
<span class="ruby-comment cmt"># File lib/slave.rb, line 323</span>
|
852
|
+
323: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wait</span> <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>
|
853
|
+
324: <span class="ruby-comment cmt">#--{{{</span>
|
854
|
+
325: <span class="ruby-identifier">b</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">lambda</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">exit_status</span><span class="ruby-operator">|</span>}
|
855
|
+
326: <span class="ruby-identifier">non_block</span> = <span class="ruby-identifier">getopts</span>(<span class="ruby-identifier">opts</span>)[<span class="ruby-value str">'non_block'</span>]
|
856
|
+
327: <span class="ruby-identifier">non_block</span> <span class="ruby-value">? </span><span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>{ <span class="ruby-identifier">b</span>[ <span class="ruby-ivar">@waiter</span>.<span class="ruby-identifier">value</span> ] } <span class="ruby-operator">:</span> <span class="ruby-identifier">b</span>[ <span class="ruby-ivar">@waiter</span>.<span class="ruby-identifier">value</span> ]
|
857
|
+
328: <span class="ruby-comment cmt">#--}}}</span>
|
858
|
+
329: <span class="ruby-keyword kw">end</span>
|
626
859
|
</pre>
|
627
860
|
</div>
|
628
861
|
</div>
|
629
862
|
</div>
|
630
863
|
|
631
|
-
<div id="method-
|
632
|
-
<a name="
|
864
|
+
<div id="method-M000008" class="method-detail">
|
865
|
+
<a name="M000008"></a>
|
633
866
|
|
634
867
|
<div class="method-heading">
|
635
|
-
<span class="method-name">wait2</span><span class="method-args">
|
868
|
+
<span class="method-name">wait2</span><span class="method-args">opts = {}, &b</span>
|
636
869
|
</div>
|
637
870
|
|
638
871
|
<div class="method-description">
|
639
872
|
<p>
|
640
|
-
Alias for <a href="Slave.html#
|
873
|
+
Alias for <a href="Slave.html#M000007">wait</a>
|
641
874
|
</p>
|
642
875
|
</div>
|
643
876
|
</div>
|