job_boss 0.5.0 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +39 -7
- data/bin/job_boss +4 -2
- data/doc/ActiveSupport/TestCase.html +106 -87
- data/doc/ActiveSupport.html +6 -0
- data/doc/CreateJobs.html +17 -5
- data/doc/DaemonTest.html +6 -0
- data/doc/Gemfile.html +128 -0
- data/doc/JobBoss/Boss.html +193 -144
- data/doc/JobBoss/Config.html +8 -2
- data/doc/JobBoss/Job.html +224 -166
- data/doc/JobBoss/Queuer.html +25 -11
- data/doc/JobBoss.html +9 -0
- data/doc/MIT-LICENSE.html +137 -0
- data/doc/MathJobs.html +6 -0
- data/doc/Penguin.html +223 -0
- data/doc/Rakefile.html +6 -0
- data/doc/SleepJobs.html +6 -0
- data/doc/StringJobs.html +7 -1
- data/doc/bin/job_boss.html +3 -1
- data/doc/created.rid +17 -11
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +12 -0
- data/doc/init_rb.html +54 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/job_boss/boss_rb.html +1 -1
- data/doc/lib/job_boss/config_rb.html +1 -1
- data/doc/lib/job_boss/job_rb.html +1 -1
- data/doc/lib/job_boss/queuer_rb.html +1 -1
- data/doc/lib/job_boss_rb.html +56 -0
- data/doc/lib/migrate_rb.html +1 -1
- data/doc/test/app_root/app/jobs/string_jobs_rb.html +1 -1
- data/doc/test/app_root/app/models/penguin_rb.html +52 -0
- data/doc/test/app_root/config/environment_rb.html +56 -0
- data/doc/test/test_helper_rb.html +3 -1
- data/doc/test/unit/job_test_rb.html +2 -4
- data/job_boss.gemspec +1 -1
- data/lib/job_boss/config.rb +2 -2
- data/lib/job_boss/job.rb +22 -2
- data/lib/job_boss/queuer.rb +10 -2
- data/lib/migrate.rb +6 -0
- data/test/app_root/app/models/penguin.rb +9 -0
- data/test/app_root/config/database.yml +3 -3
- data/test/app_root/config/environment.rb +3 -0
- data/test/test_helper.rb +6 -4
- data/test/unit/job_test.rb +33 -17
- metadata +38 -9
data/README.markdown
CHANGED
@@ -2,12 +2,19 @@
|
|
2
2
|
|
3
3
|
## Credits
|
4
4
|
|
5
|
-
The idea for this gem came from trying to use working/starling and not having much success with stability.
|
5
|
+
The idea for this gem came from trying to use working/starling and not having much success with stability. I created job_boss after some discussions with my colleagues (Neil Cook and Justin Hahn). Thanks also to my employer, [RBM Technologies](http://www.rbmtechnologies.com) for letting me take some of this work open-source.
|
6
6
|
|
7
7
|
## Purpose
|
8
8
|
|
9
9
|
job_boss allows you to have a daemon much in the same way as workling which allows you to process a series of jobs asynchronously. job_boss, however, uses ActiveRecord to store queued job requests in a database thus simplifying dependencies. This allows for us to process chunks of work in parallel, across multiple servers, without needing much setup
|
10
10
|
|
11
|
+
## Overview
|
12
|
+
|
13
|
+
* job_boss uses ActiveRecord to store/poll it's queue. It's not dependent on Rails, but if it sees that it's being run in a Rails environment, it will automatically load the environment.rb file
|
14
|
+
* Loading up the environment.rb file isn't a big deal because job_boss's model has a main "boss" process which is a deamon. The boss forks employees as needed to execute jobs.
|
15
|
+
* Employees only exist for the span of one job, so there's less concern about a build up in memory from leaks (not that we shouldn't be addressing leaks...)
|
16
|
+
* The boss is independent and always polling, so it can look for jobs which have been marked an cancelled and kill the employee during processing
|
17
|
+
|
11
18
|
## Usage
|
12
19
|
|
13
20
|
Add the gem to your Gemfile
|
@@ -27,6 +34,17 @@ Create a directory to store classes which define code which can be executed by t
|
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
37
|
+
If you're using Rails, much of the logic that you'll want to queue may already be in models or other application classes. You can queue class methods rather that needing to wrap them in a Job class:
|
38
|
+
|
39
|
+
# app/models/article.rb
|
40
|
+
class Article < ActiveRecord::Base
|
41
|
+
class << self
|
42
|
+
def refresh_cache(article_ids)
|
43
|
+
# code to refresh article cache
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
30
48
|
Start up your boss:
|
31
49
|
|
32
50
|
job_boss start -- <options>
|
@@ -46,16 +64,29 @@ But since you don't want to do that right now, it looks something like this:
|
|
46
64
|
-s, --sleep-interval INTERVAL Number of seconds for the boss to sleep between checks of the queue (default 0.5)
|
47
65
|
-c, --employee-limit LIMIT Maximum number of employees (default 4)
|
48
66
|
|
49
|
-
From your Rails code or in a console
|
67
|
+
From your Rails code or in a console:
|
50
68
|
|
51
|
-
require 'job_boss
|
69
|
+
require 'job_boss'
|
52
70
|
jobs = (0..1000).collect do |i|
|
53
|
-
|
71
|
+
Boss.queue.math.is_prime?(i)
|
54
72
|
end
|
55
73
|
|
56
|
-
|
74
|
+
Or:
|
75
|
+
|
76
|
+
jobs = []
|
77
|
+
Article.select('id').find_in_batches(:batch_size => 10) do |articles|
|
78
|
+
jobs << Boss.queue.article.refresh_cache(articles.collect(&:id))
|
79
|
+
end
|
80
|
+
|
81
|
+
job_boss also makes it easy to wait for the jobs to be done and to collect the results into a hash:
|
82
|
+
|
83
|
+
Job.wait_for_jobs(jobs) # Will sleep until the jobs are all complete
|
84
|
+
|
85
|
+
Job.result_hash(jobs) # => {[0]=>false, [1]=>false, [2]=>true, [3]=>true, [4]=>false, ... }
|
86
|
+
|
87
|
+
For performance, it is recommended that you keep your jobs table clean scheduling execution of the `delete_jobs_before` command on the Job model, which will clean all jobs completed before the specified time:
|
57
88
|
|
58
|
-
|
89
|
+
Job.delete_jobs_before(2.days.ago)
|
59
90
|
|
60
91
|
Features:
|
61
92
|
|
@@ -63,4 +94,5 @@ Features:
|
|
63
94
|
* Call the `mark_for_redo` method on a job to have it processed again. This is automatically run for all currently running jobs in the event that the boss has been told to stop
|
64
95
|
* If a job throws an exception, it will be caught and recorded. Call the `error` method on a job to find out what the error was
|
65
96
|
* Find out how long the job took by calling the `time_taken` method on a job
|
66
|
-
* The job boss dispatches "employees" to work on jobs. Viewing the processes, the process name is changed to reflect which jobs employees are working on for easy tracing (e.g. `[job_boss
|
97
|
+
* The job boss dispatches "employees" to work on jobs. Viewing the processes, the process name is changed to reflect which jobs employees are working on for easy tracing (e.g. `[job_boss employee] job #4 math#is_prime?(4)`)
|
98
|
+
|
data/bin/job_boss
CHANGED
@@ -15,8 +15,6 @@ daemons_options = {
|
|
15
15
|
Daemons.run_proc('job_boss', daemons_options) do
|
16
16
|
Dir.chdir(working_dir)
|
17
17
|
|
18
|
-
require 'config/environment' if File.exist?('config/environment.rb')
|
19
|
-
|
20
18
|
$: << File.expand_path('../../lib', __FILE__)
|
21
19
|
require 'job_boss/boss'
|
22
20
|
|
@@ -24,6 +22,10 @@ Daemons.run_proc('job_boss', daemons_options) do
|
|
24
22
|
|
25
23
|
JobBoss::Boss.config.parse_args(app_options, :working_dir => working_dir)
|
26
24
|
|
25
|
+
Dir.chdir(JobBoss::Boss.config.application_root)
|
26
|
+
|
27
|
+
require 'config/environment' if File.exist?('config/environment.rb')
|
28
|
+
|
27
29
|
boss = JobBoss::Boss.new
|
28
30
|
|
29
31
|
boss.start
|
@@ -104,6 +104,10 @@
|
|
104
104
|
<h3 class="section-header">Files</h3>
|
105
105
|
<ul>
|
106
106
|
|
107
|
+
<li class="file"><a href="../Gemfile.html">Gemfile</a></li>
|
108
|
+
|
109
|
+
<li class="file"><a href="../MIT-LICENSE.html">MIT-LICENSE</a></li>
|
110
|
+
|
107
111
|
<li class="file"><a href="../Rakefile.html">Rakefile</a></li>
|
108
112
|
|
109
113
|
</ul>
|
@@ -145,6 +149,8 @@
|
|
145
149
|
|
146
150
|
<li><a href="../MathJobs.html">MathJobs</a></li>
|
147
151
|
|
152
|
+
<li><a href="../Penguin.html">Penguin</a></li>
|
153
|
+
|
148
154
|
<li><a href="../SleepJobs.html">SleepJobs</a></li>
|
149
155
|
|
150
156
|
<li><a href="../StringJobs.html">StringJobs</a></li>
|
@@ -182,7 +188,7 @@
|
|
182
188
|
<div class="method-heading">
|
183
189
|
|
184
190
|
<span class="method-name">assert_pid_not_running</span><span
|
185
|
-
class="method-args">(pid)</span>
|
191
|
+
class="method-args">(pid, message="")</span>
|
186
192
|
<span class="method-click-advice">click to toggle source</span>
|
187
193
|
|
188
194
|
</div>
|
@@ -196,12 +202,18 @@
|
|
196
202
|
<div class="method-source-code"
|
197
203
|
id="assert-pid-not-running-source">
|
198
204
|
<pre>
|
199
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 43</span>
|
206
|
+
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_pid_not_running</span>(<span class="ruby-identifier">pid</span>, <span class="ruby-identifier">message</span>=<span class="ruby-value str">""</span>)
|
207
|
+
44: <span class="ruby-identifier">full_message</span> = <span class="ruby-identifier">build_message</span>(<span class="ruby-identifier">message</span>, <span class="ruby-value str">"PID <?> expected to not be running."</span>, <span class="ruby-identifier">pid</span>)
|
208
|
+
45: <span class="ruby-identifier">assert_block</span>(<span class="ruby-identifier">full_message</span>) <span class="ruby-keyword kw">do</span>
|
209
|
+
46: <span class="ruby-keyword kw">begin</span>
|
210
|
+
47: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">to_i</span>)
|
211
|
+
48: <span class="ruby-keyword kw">false</span>
|
212
|
+
49: <span class="ruby-keyword kw">rescue</span>
|
213
|
+
50: <span class="ruby-keyword kw">true</span>
|
214
|
+
51: <span class="ruby-keyword kw">end</span>
|
215
|
+
52: <span class="ruby-keyword kw">end</span>
|
216
|
+
53: <span class="ruby-keyword kw">end</span></pre>
|
205
217
|
</div>
|
206
218
|
|
207
219
|
</div>
|
@@ -218,7 +230,7 @@
|
|
218
230
|
<div class="method-heading">
|
219
231
|
|
220
232
|
<span class="method-name">assert_pid_running</span><span
|
221
|
-
class="method-args">(pid)</span>
|
233
|
+
class="method-args">(pid, message="")</span>
|
222
234
|
<span class="method-click-advice">click to toggle source</span>
|
223
235
|
|
224
236
|
</div>
|
@@ -232,12 +244,18 @@
|
|
232
244
|
<div class="method-source-code"
|
233
245
|
id="assert-pid-running-source">
|
234
246
|
<pre>
|
235
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
247
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 31</span>
|
248
|
+
31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-identifier">pid</span>, <span class="ruby-identifier">message</span>=<span class="ruby-value str">""</span>)
|
249
|
+
32: <span class="ruby-identifier">full_message</span> = <span class="ruby-identifier">build_message</span>(<span class="ruby-identifier">message</span>, <span class="ruby-value str">"PID <?> expected to be running."</span>, <span class="ruby-identifier">pid</span>)
|
250
|
+
33: <span class="ruby-identifier">assert_block</span>(<span class="ruby-identifier">full_message</span>) <span class="ruby-keyword kw">do</span>
|
251
|
+
34: <span class="ruby-keyword kw">begin</span>
|
252
|
+
35: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">to_i</span>)
|
253
|
+
36: <span class="ruby-keyword kw">true</span>
|
254
|
+
37: <span class="ruby-keyword kw">rescue</span>
|
255
|
+
38: <span class="ruby-keyword kw">false</span>
|
256
|
+
39: <span class="ruby-keyword kw">end</span>
|
257
|
+
40: <span class="ruby-keyword kw">end</span>
|
258
|
+
41: <span class="ruby-keyword kw">end</span></pre>
|
241
259
|
</div>
|
242
260
|
|
243
261
|
</div>
|
@@ -268,11 +286,11 @@
|
|
268
286
|
<div class="method-source-code"
|
269
287
|
id="clean-app-environment-source">
|
270
288
|
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
289
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 26</span>
|
290
|
+
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clean_app_environment</span>
|
291
|
+
27: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@db_path</span>, <span class="ruby-value str">'*'</span>)).<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span>(<span class="ruby-identifier">path</span>) }
|
292
|
+
28: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@app_root_path</span>, <span class="ruby-value str">'log'</span>, <span class="ruby-value str">'*'</span>)).<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span>(<span class="ruby-identifier">path</span>) }
|
293
|
+
29: <span class="ruby-keyword kw">end</span></pre>
|
276
294
|
</div>
|
277
295
|
|
278
296
|
</div>
|
@@ -303,10 +321,10 @@
|
|
303
321
|
<div class="method-source-code"
|
304
322
|
id="get-pid-from-startup-source">
|
305
323
|
<pre>
|
306
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
307
|
-
|
308
|
-
|
309
|
-
|
324
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 73</span>
|
325
|
+
73: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
|
326
|
+
74: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/job_boss: process with pid (\d+) started./</span>)[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>
|
327
|
+
75: <span class="ruby-keyword kw">end</span></pre>
|
310
328
|
</div>
|
311
329
|
|
312
330
|
</div>
|
@@ -337,20 +355,20 @@
|
|
337
355
|
<div class="method-source-code"
|
338
356
|
id="restart-daemon-source">
|
339
357
|
<pre>
|
340
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
358
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 102</span>
|
359
|
+
102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart_daemon</span>
|
360
|
+
103: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
|
361
|
+
104:
|
362
|
+
105: <span class="ruby-identifier">output</span> = <span class="ruby-node">`#{@job_boss_bin_path} restart`</span>
|
363
|
+
106:
|
364
|
+
107: <span class="ruby-comment cmt"># Give the daemon a bit of time to stop</span>
|
365
|
+
108: <span class="ruby-comment cmt"># sleep(0.5)</span>
|
366
|
+
109: <span class="ruby-identifier">assert_pid_not_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
|
367
|
+
110:
|
368
|
+
111: <span class="ruby-ivar">@daemon_pid</span> = <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
|
369
|
+
112:
|
370
|
+
113: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
|
371
|
+
114: <span class="ruby-keyword kw">end</span></pre>
|
354
372
|
</div>
|
355
373
|
|
356
374
|
</div>
|
@@ -381,13 +399,14 @@
|
|
381
399
|
<div class="method-source-code"
|
382
400
|
id="setup-paths-source">
|
383
401
|
<pre>
|
384
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
402
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 18</span>
|
403
|
+
18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_paths</span>
|
404
|
+
19: <span class="ruby-ivar">@job_boss_bin_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-value str">'../../bin/job_boss'</span>, <span class="ruby-keyword kw">__FILE__</span>)
|
405
|
+
20: <span class="ruby-ivar">@app_root_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-value str">'../app_root'</span>, <span class="ruby-keyword kw">__FILE__</span>)
|
406
|
+
21: <span class="ruby-ivar">@db_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@app_root_path</span>, <span class="ruby-value str">'db'</span>)
|
407
|
+
22: <span class="ruby-ivar">@log_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@app_root_path</span>, <span class="ruby-value str">'log'</span>, <span class="ruby-value str">'job_boss.log'</span>)
|
408
|
+
23: <span class="ruby-ivar">@db_yaml_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@app_root_path</span>, <span class="ruby-value str">'config'</span>, <span class="ruby-value str">'database.yml'</span>)
|
409
|
+
24: <span class="ruby-keyword kw">end</span></pre>
|
391
410
|
</div>
|
392
411
|
|
393
412
|
</div>
|
@@ -418,24 +437,24 @@
|
|
418
437
|
<div class="method-source-code"
|
419
438
|
id="start-daemon-source">
|
420
439
|
<pre>
|
421
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
440
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 55</span>
|
441
|
+
55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_daemon</span>(<span class="ruby-identifier">options</span>)
|
442
|
+
56: <span class="ruby-identifier">clean_app_environment</span>
|
443
|
+
57:
|
444
|
+
58: <span class="ruby-identifier">stop_daemon</span>
|
445
|
+
59:
|
446
|
+
60: <span class="ruby-identifier">option_string</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
447
|
+
61: <span class="ruby-value str">'--'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'_'</span>, <span class="ruby-value str">'-'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">" "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
|
448
|
+
62: <span class="ruby-keyword kw">end</span>
|
449
|
+
63:
|
450
|
+
64: <span class="ruby-identifier">output</span> = <span class="ruby-node">`#{@job_boss_bin_path} start -- #{option_string.join(' ')}`</span>
|
451
|
+
65:
|
452
|
+
66: <span class="ruby-ivar">@daemon_pid</span> = <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
|
453
|
+
67:
|
454
|
+
68: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
|
455
|
+
69:
|
456
|
+
70: <span class="ruby-ivar">@daemon_pid</span>
|
457
|
+
71: <span class="ruby-keyword kw">end</span></pre>
|
439
458
|
</div>
|
440
459
|
|
441
460
|
</div>
|
@@ -466,14 +485,14 @@
|
|
466
485
|
<div class="method-source-code"
|
467
486
|
id="stop-daemon-source">
|
468
487
|
<pre>
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
488
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 94</span>
|
489
|
+
94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_daemon</span>
|
490
|
+
95: <span class="ruby-node">`#{@job_boss_bin_path} stop`</span>
|
491
|
+
96:
|
492
|
+
97: <span class="ruby-comment cmt"># Give the daemon a bit of time to stop</span>
|
493
|
+
98: <span class="ruby-comment cmt"># sleep(0.5)</span>
|
494
|
+
99: <span class="ruby-identifier">assert_pid_not_running</span>(<span class="ruby-ivar">@daemon_pid</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@daemon_pid</span>
|
495
|
+
100: <span class="ruby-keyword kw">end</span></pre>
|
477
496
|
</div>
|
478
497
|
|
479
498
|
</div>
|
@@ -504,16 +523,16 @@
|
|
504
523
|
<div class="method-source-code"
|
505
524
|
id="wait-for-file-source">
|
506
525
|
<pre>
|
507
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
526
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 77</span>
|
527
|
+
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wait_for_file</span>(<span class="ruby-identifier">file_path</span>, <span class="ruby-identifier">timeout</span> = <span class="ruby-value">5</span>)
|
528
|
+
78: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
|
529
|
+
79: <span class="ruby-keyword kw">until</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">file_path</span>)
|
530
|
+
80: <span class="ruby-identifier">sleep</span>(<span class="ruby-value">1</span>)
|
531
|
+
81:
|
532
|
+
82: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"File failed to appear!"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">></span> <span class="ruby-identifier">timeout</span>
|
533
|
+
83: <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
534
|
+
84: <span class="ruby-keyword kw">end</span>
|
535
|
+
85: <span class="ruby-keyword kw">end</span></pre>
|
517
536
|
</div>
|
518
537
|
|
519
538
|
</div>
|
@@ -544,13 +563,13 @@
|
|
544
563
|
<div class="method-source-code"
|
545
564
|
id="wait-until-job-assigned-source">
|
546
565
|
<pre>
|
547
|
-
<span class="ruby-comment cmt"># File test/test_helper.rb, line
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
566
|
+
<span class="ruby-comment cmt"># File test/test_helper.rb, line 87</span>
|
567
|
+
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wait_until_job_assigned</span>(<span class="ruby-identifier">job</span>, <span class="ruby-identifier">wait_interval</span> = <span class="ruby-value">0.5</span>)
|
568
|
+
88: <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">job</span>.<span class="ruby-identifier">assigned?</span>
|
569
|
+
89: <span class="ruby-identifier">sleep</span>(<span class="ruby-identifier">wait_interval</span>)
|
570
|
+
90: <span class="ruby-identifier">job</span>.<span class="ruby-identifier">reload</span>
|
571
|
+
91: <span class="ruby-keyword kw">end</span>
|
572
|
+
92: <span class="ruby-keyword kw">end</span></pre>
|
554
573
|
</div>
|
555
574
|
|
556
575
|
</div>
|
data/doc/ActiveSupport.html
CHANGED
@@ -76,6 +76,10 @@
|
|
76
76
|
<h3 class="section-header">Files</h3>
|
77
77
|
<ul>
|
78
78
|
|
79
|
+
<li class="file"><a href="./Gemfile.html">Gemfile</a></li>
|
80
|
+
|
81
|
+
<li class="file"><a href="./MIT-LICENSE.html">MIT-LICENSE</a></li>
|
82
|
+
|
79
83
|
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
80
84
|
|
81
85
|
</ul>
|
@@ -117,6 +121,8 @@
|
|
117
121
|
|
118
122
|
<li><a href="./MathJobs.html">MathJobs</a></li>
|
119
123
|
|
124
|
+
<li><a href="./Penguin.html">Penguin</a></li>
|
125
|
+
|
120
126
|
<li><a href="./SleepJobs.html">SleepJobs</a></li>
|
121
127
|
|
122
128
|
<li><a href="./StringJobs.html">StringJobs</a></li>
|
data/doc/CreateJobs.html
CHANGED
@@ -88,6 +88,10 @@
|
|
88
88
|
<h3 class="section-header">Files</h3>
|
89
89
|
<ul>
|
90
90
|
|
91
|
+
<li class="file"><a href="./Gemfile.html">Gemfile</a></li>
|
92
|
+
|
93
|
+
<li class="file"><a href="./MIT-LICENSE.html">MIT-LICENSE</a></li>
|
94
|
+
|
91
95
|
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
92
96
|
|
93
97
|
</ul>
|
@@ -129,6 +133,8 @@
|
|
129
133
|
|
130
134
|
<li><a href="./MathJobs.html">MathJobs</a></li>
|
131
135
|
|
136
|
+
<li><a href="./Penguin.html">Penguin</a></li>
|
137
|
+
|
132
138
|
<li><a href="./SleepJobs.html">SleepJobs</a></li>
|
133
139
|
|
134
140
|
<li><a href="./StringJobs.html">StringJobs</a></li>
|
@@ -180,10 +186,10 @@
|
|
180
186
|
<div class="method-source-code"
|
181
187
|
id="down-source">
|
182
188
|
<pre>
|
183
|
-
<span class="ruby-comment cmt"># File lib/migrate.rb, line
|
184
|
-
|
185
|
-
|
186
|
-
|
189
|
+
<span class="ruby-comment cmt"># File lib/migrate.rb, line 32</span>
|
190
|
+
32: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">down</span>
|
191
|
+
33: <span class="ruby-identifier">drop_table</span> <span class="ruby-value">:jobs</span>
|
192
|
+
34: <span class="ruby-keyword kw">end</span></pre>
|
187
193
|
</div>
|
188
194
|
|
189
195
|
</div>
|
@@ -237,7 +243,13 @@
|
|
237
243
|
21:
|
238
244
|
22: <span class="ruby-identifier">add_index</span> <span class="ruby-value">:jobs</span>, <span class="ruby-value">:path</span>
|
239
245
|
23: <span class="ruby-identifier">add_index</span> <span class="ruby-value">:jobs</span>, <span class="ruby-value">:status</span>
|
240
|
-
24:
|
246
|
+
24:
|
247
|
+
25: <span class="ruby-identifier">postgres</span> = (<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">adapter_name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'PostgreSQL'</span>)
|
248
|
+
26:
|
249
|
+
27: [<span class="ruby-value str">'started_at'</span>, <span class="ruby-value str">'cancelled_at'</span>, <span class="ruby-value str">'completed_at'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">field</span><span class="ruby-operator">|</span>
|
250
|
+
28: <span class="ruby-identifier">execute</span> <span class="ruby-node">"CREATE INDEX IF NOT EXISTS jobs_#{field}_is_null ON jobs (#{field})"</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">postgres</span> <span class="ruby-operator">?</span> <span class="ruby-node">" WHERE #{field} IS NULL"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>)
|
251
|
+
29: <span class="ruby-keyword kw">end</span>
|
252
|
+
30: <span class="ruby-keyword kw">end</span></pre>
|
241
253
|
</div>
|
242
254
|
|
243
255
|
</div>
|
data/doc/DaemonTest.html
CHANGED
@@ -80,6 +80,10 @@
|
|
80
80
|
<h3 class="section-header">Files</h3>
|
81
81
|
<ul>
|
82
82
|
|
83
|
+
<li class="file"><a href="./Gemfile.html">Gemfile</a></li>
|
84
|
+
|
85
|
+
<li class="file"><a href="./MIT-LICENSE.html">MIT-LICENSE</a></li>
|
86
|
+
|
83
87
|
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
84
88
|
|
85
89
|
</ul>
|
@@ -121,6 +125,8 @@
|
|
121
125
|
|
122
126
|
<li><a href="./MathJobs.html">MathJobs</a></li>
|
123
127
|
|
128
|
+
<li><a href="./Penguin.html">Penguin</a></li>
|
129
|
+
|
124
130
|
<li><a href="./SleepJobs.html">SleepJobs</a></li>
|
125
131
|
|
126
132
|
<li><a href="./StringJobs.html">StringJobs</a></li>
|