thinner 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README +17 -0
- data/Rakefile +64 -0
- data/VERSION +1 -0
- data/bin/thinner +4 -0
- data/doc/Thinner/Client.html +602 -0
- data/doc/Thinner/CommandLine.html +291 -0
- data/doc/Thinner/Configuration.html +592 -0
- data/doc/Thinner/Purger.html +433 -0
- data/doc/Thinner.html +455 -0
- data/doc/_index.html +138 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +307 -0
- data/doc/file.README.html +71 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +71 -0
- data/doc/js/app.js +202 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +211 -0
- data/doc/top-level-namespace.html +88 -0
- data/documentation/css/dawn.css +121 -0
- data/documentation/css/styles.css +53 -0
- data/documentation/examples/configure.rb +25 -0
- data/documentation/examples/purge.rb +5 -0
- data/documentation/images/proplogo.png +0 -0
- data/documentation/index.html.erb +64 -0
- data/index.html +87 -0
- data/lib/thinner/client.rb +88 -0
- data/lib/thinner/command_line.rb +80 -0
- data/lib/thinner/configuration.rb +37 -0
- data/lib/thinner/purger.rb +46 -0
- data/lib/thinner.rb +37 -0
- data/test/helper.rb +10 -0
- data/test/test_thinner.rb +32 -0
- data/thinner.gemspec +90 -0
- metadata +138 -0
@@ -0,0 +1,433 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>Class: Thinner::Purger</title>
|
7
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="../_index.html">Index (P)</a> »
|
27
|
+
<span class='title'><span class='object_link'><a href="../Thinner.html" title="Thinner (module)">Thinner</a></span></span>
|
28
|
+
»
|
29
|
+
<span class="title">Purger</span>
|
30
|
+
|
31
|
+
|
32
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="search">
|
36
|
+
<a id="class_list_link" href="#">Class List</a>
|
37
|
+
<a id="method_list_link" href="#">Method List</a>
|
38
|
+
<a id ="file_list_link" href="#">File List</a>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="clear"></div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<iframe id="search_frame"></iframe>
|
45
|
+
|
46
|
+
<div id="content"><h1>Class: Thinner::Purger
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
</h1>
|
51
|
+
|
52
|
+
<dl class="box">
|
53
|
+
|
54
|
+
<dt class="r1">Inherits:</dt>
|
55
|
+
<dd class="r1">
|
56
|
+
<span class="inheritName">Object</span>
|
57
|
+
|
58
|
+
<ul class="fullTree">
|
59
|
+
<li>Object</li>
|
60
|
+
|
61
|
+
<li class="next">Thinner::Purger</li>
|
62
|
+
|
63
|
+
</ul>
|
64
|
+
<a href="#" class="inheritanceTree">show all</a>
|
65
|
+
|
66
|
+
</dd>
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
<dt class="r2 last">Defined in:</dt>
|
77
|
+
<dd class="r2 last">lib/thinner/purger.rb</dd>
|
78
|
+
|
79
|
+
</dl>
|
80
|
+
<div class="clear"></div>
|
81
|
+
|
82
|
+
<h2>Overview</h2><div class="docstring">
|
83
|
+
<div class="discussion">
|
84
|
+
<p>
|
85
|
+
A Thinner::Purger dispatches a client and ensures only one instance of a
|
86
|
+
Thinner::Client is running at a given time.
|
87
|
+
</p>
|
88
|
+
|
89
|
+
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
<div class="tags">
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
<h2>
|
99
|
+
Class Method Summary
|
100
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
101
|
+
</h2>
|
102
|
+
|
103
|
+
<ul class="summary">
|
104
|
+
|
105
|
+
<li class="public ">
|
106
|
+
<span class="summary_signature">
|
107
|
+
|
108
|
+
<a href="#job_ids-class_method" title="job_ids (class method)">+ (Object) <strong>job_ids</strong> </a>
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
</span>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<span class="summary_desc"><div class='inline'><p>
|
122
|
+
A list of Thinner::Client process ids — adapted from resque.
|
123
|
+
</p>
|
124
|
+
</div></span>
|
125
|
+
|
126
|
+
</li>
|
127
|
+
|
128
|
+
|
129
|
+
<li class="public ">
|
130
|
+
<span class="summary_signature">
|
131
|
+
|
132
|
+
<a href="#stop%21-class_method" title="stop! (class method)">+ (Object) <strong>stop!</strong> </a>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
</span>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'><p>
|
146
|
+
Before we spin up a new client each running process is killed by pid.
|
147
|
+
</p>
|
148
|
+
</div></span>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
|
152
|
+
|
153
|
+
</ul>
|
154
|
+
|
155
|
+
<h2>
|
156
|
+
Instance Method Summary
|
157
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
158
|
+
</h2>
|
159
|
+
|
160
|
+
<ul class="summary">
|
161
|
+
|
162
|
+
<li class="public ">
|
163
|
+
<span class="summary_signature">
|
164
|
+
|
165
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Purger) <strong>initialize</strong>(urls) </a>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
</span>
|
170
|
+
|
171
|
+
<span class="note title constructor">constructor</span>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
<span class="summary_desc"><div class='inline'><p>
|
181
|
+
Each Purger accepts a list of urls to pass on to the client to purge.
|
182
|
+
</p>
|
183
|
+
</div></span>
|
184
|
+
|
185
|
+
</li>
|
186
|
+
|
187
|
+
|
188
|
+
<li class="public ">
|
189
|
+
<span class="summary_signature">
|
190
|
+
|
191
|
+
<a href="#purge%21-instance_method" title="#purge! (instance method)">- (Object) <strong>purge!</strong> </a>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</span>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
<span class="summary_desc"><div class='inline'><p>
|
205
|
+
After the configuration is in place and the Purger has a list of urls, it
|
206
|
+
can fork a client process to run in the background.
|
207
|
+
</p>
|
208
|
+
</div></span>
|
209
|
+
|
210
|
+
</li>
|
211
|
+
|
212
|
+
|
213
|
+
</ul>
|
214
|
+
|
215
|
+
|
216
|
+
<div id="constructor_details" class="method_details_list">
|
217
|
+
<h2>Constructor Details</h2>
|
218
|
+
|
219
|
+
<div class="method_details first">
|
220
|
+
<p class="signature first" id="initialize-instance_method">
|
221
|
+
|
222
|
+
- (<tt><span class='object_link'><a href="" title="Thinner::Purger (class)">Purger</a></span></tt>) <strong>initialize</strong>(urls)
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
</p><div class="docstring">
|
227
|
+
<div class="discussion">
|
228
|
+
<p>
|
229
|
+
Each Purger accepts a list of urls to pass on to the client to purge.
|
230
|
+
</p>
|
231
|
+
|
232
|
+
|
233
|
+
</div>
|
234
|
+
</div>
|
235
|
+
<div class="tags">
|
236
|
+
|
237
|
+
</div><table class="source_code">
|
238
|
+
<tr>
|
239
|
+
<td>
|
240
|
+
<pre class="lines">
|
241
|
+
|
242
|
+
|
243
|
+
8
|
244
|
+
9
|
245
|
+
10</pre>
|
246
|
+
</td>
|
247
|
+
<td>
|
248
|
+
<pre class="code"><span class="info file"># File 'lib/thinner/purger.rb', line 8</span>
|
249
|
+
|
250
|
+
<span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='urls identifier id'>urls</span><span class='rparen token'>)</span>
|
251
|
+
<span class='@urls ivar id'>@urls</span> <span class='assign token'>=</span> <span class='urls identifier id'>urls</span>
|
252
|
+
<span class='end end kw'>end</span>
|
253
|
+
</pre>
|
254
|
+
</td>
|
255
|
+
</tr>
|
256
|
+
</table>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
|
262
|
+
<div id="class_method_details" class="method_details_list">
|
263
|
+
<h2>Class Method Details</h2>
|
264
|
+
|
265
|
+
|
266
|
+
<div class="method_details first">
|
267
|
+
<p class="signature first" id="job_ids-class_method">
|
268
|
+
|
269
|
+
+ (<tt>Object</tt>) <strong>job_ids</strong>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
</p><div class="docstring">
|
274
|
+
<div class="discussion">
|
275
|
+
<p>
|
276
|
+
A list of Thinner::Client process ids — adapted from resque.
|
277
|
+
</p>
|
278
|
+
|
279
|
+
|
280
|
+
</div>
|
281
|
+
</div>
|
282
|
+
<div class="tags">
|
283
|
+
|
284
|
+
</div><table class="source_code">
|
285
|
+
<tr>
|
286
|
+
<td>
|
287
|
+
<pre class="lines">
|
288
|
+
|
289
|
+
|
290
|
+
26
|
291
|
+
27
|
292
|
+
28
|
293
|
+
29
|
294
|
+
30</pre>
|
295
|
+
</td>
|
296
|
+
<td>
|
297
|
+
<pre class="code"><span class="info file"># File 'lib/thinner/purger.rb', line 26</span>
|
298
|
+
|
299
|
+
<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='job_ids identifier id'>job_ids</span>
|
300
|
+
<span class='lines identifier id'>lines</span> <span class='assign token'>=</span> <span class='dxstring node'>`ps -A -o pid,command | grep #{PROCESS_IDENTIFIER}`</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='string val'>"\n"</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='map identifier id'>map</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='line identifier id'>line</span><span class='bitor op'>|</span>
|
301
|
+
<span class='line identifier id'>line</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='string val'>' '</span><span class='rparen token'>)</span><span class='lbrack token'>[</span><span class='integer val'>0</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='to_i identifier id'>to_i</span>
|
302
|
+
<span class='end end kw'>end</span>
|
303
|
+
<span class='end end kw'>end</span>
|
304
|
+
</pre>
|
305
|
+
</td>
|
306
|
+
</tr>
|
307
|
+
</table>
|
308
|
+
</div>
|
309
|
+
|
310
|
+
<div class="method_details ">
|
311
|
+
<p class="signature " id="stop!-class_method">
|
312
|
+
|
313
|
+
+ (<tt>Object</tt>) <strong>stop!</strong>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
</p><div class="docstring">
|
318
|
+
<div class="discussion">
|
319
|
+
<p>
|
320
|
+
Before we spin up a new client each running process is killed by pid. Each
|
321
|
+
killed process’s id is logged in the Thinner log file.
|
322
|
+
</p>
|
323
|
+
|
324
|
+
|
325
|
+
</div>
|
326
|
+
</div>
|
327
|
+
<div class="tags">
|
328
|
+
|
329
|
+
</div><table class="source_code">
|
330
|
+
<tr>
|
331
|
+
<td>
|
332
|
+
<pre class="lines">
|
333
|
+
|
334
|
+
|
335
|
+
34
|
336
|
+
35
|
337
|
+
36
|
338
|
+
37
|
339
|
+
38
|
340
|
+
39
|
341
|
+
40
|
342
|
+
41
|
343
|
+
42</pre>
|
344
|
+
</td>
|
345
|
+
<td>
|
346
|
+
<pre class="code"><span class="info file"># File 'lib/thinner/purger.rb', line 34</span>
|
347
|
+
|
348
|
+
<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='stop! fid id'>stop!</span>
|
349
|
+
<span class='job_ids identifier id'>job_ids</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='pid identifier id'>pid</span><span class='bitor op'>|</span>
|
350
|
+
<span class='begin begin kw'>begin</span>
|
351
|
+
<span class='Process constant id'>Process</span><span class='dot token'>.</span><span class='kill identifier id'>kill</span><span class='lparen token'>(</span><span class='string val'>"KILL"</span><span class='comma token'>,</span> <span class='pid identifier id'>pid</span><span class='dot token'>.</span><span class='to_i identifier id'>to_i</span><span class='rparen token'>)</span>
|
352
|
+
<span class='puts identifier id'>puts</span> <span class='dstring node'>"==== Killing process: #{pid}"</span>
|
353
|
+
<span class='rescue rescue kw'>rescue</span> <span class='Errno constant id'>Errno</span><span class='colon2 op'>::</span><span class='ESRCH constant id'>ESRCH</span>
|
354
|
+
<span class='end end kw'>end</span>
|
355
|
+
<span class='end end kw'>end</span>
|
356
|
+
<span class='end end kw'>end</span>
|
357
|
+
</pre>
|
358
|
+
</td>
|
359
|
+
</tr>
|
360
|
+
</table>
|
361
|
+
</div>
|
362
|
+
|
363
|
+
</div>
|
364
|
+
|
365
|
+
<div id="instance_method_details" class="method_details_list">
|
366
|
+
<h2>Instance Method Details</h2>
|
367
|
+
|
368
|
+
|
369
|
+
<div class="method_details first">
|
370
|
+
<p class="signature first" id="purge!-instance_method">
|
371
|
+
|
372
|
+
- (<tt>Object</tt>) <strong>purge!</strong>
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
</p><div class="docstring">
|
377
|
+
<div class="discussion">
|
378
|
+
<p>
|
379
|
+
After the configuration is in place and the Purger has a list of urls, it
|
380
|
+
can fork a client process to run in the background. By default the Purger
|
381
|
+
will kill any old Thinner::Client processes still running so as to not
|
382
|
+
double up on purge requests.
|
383
|
+
</p>
|
384
|
+
|
385
|
+
|
386
|
+
</div>
|
387
|
+
</div>
|
388
|
+
<div class="tags">
|
389
|
+
|
390
|
+
</div><table class="source_code">
|
391
|
+
<tr>
|
392
|
+
<td>
|
393
|
+
<pre class="lines">
|
394
|
+
|
395
|
+
|
396
|
+
16
|
397
|
+
17
|
398
|
+
18
|
399
|
+
19
|
400
|
+
20
|
401
|
+
21
|
402
|
+
22
|
403
|
+
23</pre>
|
404
|
+
</td>
|
405
|
+
<td>
|
406
|
+
<pre class="code"><span class="info file"># File 'lib/thinner/purger.rb', line 16</span>
|
407
|
+
|
408
|
+
<span class='def def kw'>def</span> <span class='purge! fid id'>purge!</span>
|
409
|
+
<span class='self self kw'>self</span><span class='dot token'>.</span><span class='class identifier id'>class</span><span class='dot token'>.</span><span class='stop! fid id'>stop!</span> <span class='unless unless_mod kw'>unless</span> <span class='Thinner constant id'>Thinner</span><span class='dot token'>.</span><span class='configuration identifier id'>configuration</span><span class='dot token'>.</span><span class='no_kill identifier id'>no_kill</span>
|
410
|
+
<span class='puts identifier id'>puts</span> <span class='dstring node'>"==== Starting purge see: #{Thinner.configuration.log_file} for finished urls."</span>
|
411
|
+
<span class='client_id identifier id'>client_id</span> <span class='assign token'>=</span> <span class='fork identifier id'>fork</span> <span class='lbrace token'>{</span>
|
412
|
+
<span class='Client constant id'>Client</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='@urls ivar id'>@urls</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='run! fid id'>run!</span>
|
413
|
+
<span class='rbrace token'>}</span>
|
414
|
+
<span class='Process constant id'>Process</span><span class='dot token'>.</span><span class='detach identifier id'>detach</span><span class='lparen token'>(</span><span class='client_id identifier id'>client_id</span><span class='rparen token'>)</span>
|
415
|
+
<span class='end end kw'>end</span>
|
416
|
+
</pre>
|
417
|
+
</td>
|
418
|
+
</tr>
|
419
|
+
</table>
|
420
|
+
</div>
|
421
|
+
|
422
|
+
</div>
|
423
|
+
|
424
|
+
</div>
|
425
|
+
|
426
|
+
<div id="footer">
|
427
|
+
Generated on Tue Nov 2 14:25:51 2010 by
|
428
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
429
|
+
0.6.1 (ruby-1.8.7).
|
430
|
+
</div>
|
431
|
+
|
432
|
+
</body>
|
433
|
+
</html>
|