job_boss 0.2 → 0.4

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.
Files changed (56) hide show
  1. data/README.markdown +25 -2
  2. data/Rakefile +21 -8
  3. data/bin/job_boss +1 -0
  4. data/doc/ActiveSupport/TestCase.html +584 -0
  5. data/doc/{Passenger.html → ActiveSupport.html} +10 -30
  6. data/doc/CreateJobs.html +31 -16
  7. data/doc/{Mongrel.html → DaemonTest.html} +23 -39
  8. data/doc/JobBoss/Boss.html +466 -68
  9. data/doc/JobBoss/Config.html +77 -39
  10. data/doc/JobBoss/Job.html +375 -97
  11. data/doc/JobBoss/Queuer.html +35 -21
  12. data/doc/JobBoss.html +14 -311
  13. data/doc/{ActiveRecord.html → MathJobs.html} +66 -36
  14. data/doc/Rakefile.html +43 -9
  15. data/doc/SleepJobs.html +251 -0
  16. data/doc/{PhusionPassenger.html → StringJobs.html} +66 -38
  17. data/doc/bin/job_boss.html +1 -1
  18. data/doc/created.rid +14 -8
  19. data/doc/index.html +63 -7
  20. data/doc/lib/job_boss/boss_rb.html +5 -1
  21. data/doc/lib/job_boss/{configuror_rb.html → config_rb.html} +2 -2
  22. data/doc/lib/job_boss/job_rb.html +3 -1
  23. data/doc/lib/job_boss/queuer_rb.html +1 -1
  24. data/doc/lib/migrate_rb.html +1 -1
  25. data/doc/{vendor/spawn/lib/spawn_rb.html → test/app_root/app/jobs/math_jobs_rb.html} +7 -7
  26. data/doc/{vendor/spawn/lib/patches_rb.html → test/app_root/app/jobs/sleep_jobs_rb.html} +8 -12
  27. data/doc/test/app_root/app/jobs/string_jobs_rb.html +52 -0
  28. data/doc/test/test_helper_rb.html +62 -0
  29. data/doc/{vendor/spawn/init_rb.html → test/unit/daemon_test_rb.html} +3 -3
  30. data/doc/test/unit/job_test_rb.html +60 -0
  31. data/job_boss.gemspec +3 -2
  32. data/lib/job_boss/boss.rb +29 -7
  33. data/lib/job_boss/config.rb +49 -0
  34. data/lib/job_boss/job.rb +57 -13
  35. data/lib/migrate.rb +3 -1
  36. data/test/app_root/app/jobs/math_jobs.rb +5 -0
  37. data/test/app_root/app/jobs/sleep_jobs.rb +9 -0
  38. data/test/app_root/app/jobs/string_jobs.rb +5 -0
  39. data/test/app_root/config/database.yml +22 -0
  40. data/test/test_helper.rb +113 -0
  41. data/test/unit/daemon_test.rb +29 -0
  42. data/test/unit/job_test.rb +73 -0
  43. metadata +46 -27
  44. data/doc/ActiveRecord/Base.html +0 -343
  45. data/doc/Mongrel/HttpServer.html +0 -275
  46. data/doc/Passenger/Railz/RequestHandler.html +0 -271
  47. data/doc/Passenger/Railz.html +0 -185
  48. data/doc/PhusionPassenger/Rack/RequestHandler.html +0 -271
  49. data/doc/PhusionPassenger/Rack.html +0 -185
  50. data/doc/PhusionPassenger/Railz/RequestHandler.html +0 -271
  51. data/doc/PhusionPassenger/Railz.html +0 -185
  52. data/doc/Spawn/SpawnId.html +0 -276
  53. data/doc/Spawn.html +0 -742
  54. data/doc/vendor/spawn/CHANGELOG.html +0 -275
  55. data/doc/vendor/spawn/LICENSE.html +0 -151
  56. data/lib/job_boss/configuror.rb +0 -40
data/README.markdown CHANGED
@@ -29,7 +29,22 @@ Create a directory to store classes which define code which can be executed by t
29
29
 
30
30
  Start up your boss:
31
31
 
32
- job_boss start
32
+ job_boss start -- <options>
33
+
34
+ You can get command line options with the command:
35
+
36
+ job_boss run -- -h
37
+
38
+ But since you don't want to do that right now, it looks something like this:
39
+
40
+ Usage: job_boss [start|stop|restart|run|zap] [-- <options>]
41
+ -r, --application-root PATH Path for the application root upon which other paths depend (defaults to .)
42
+ -d, --database-yaml PATH Path for database YAML (defaults to <application-root>/config/database.yml)
43
+ -l, --log-path PATH Path for log file (defaults to <application-root>/log/job_boss.log)
44
+ -j, --jobs-path PATH Path to folder with job classes (defaults to <application-root>/app/jobs)
45
+ -e, --environment ENV Environment to use in database YAML file (defaults to 'development')
46
+ -s, --sleep-interval INTERVAL Number of seconds for the boss to sleep between checks of the queue (default 0.5)
47
+ -c, --employee-limit LIMIT Maximum number of employees (default 4)
33
48
 
34
49
  From your Rails code or in a console (this functionality should probably be encapsulated in the job_boss gem):
35
50
 
@@ -40,4 +55,12 @@ From your Rails code or in a console (this functionality should probably be enca
40
55
 
41
56
  JobBoss::Job.wait_for_jobs(jobs) # Will sleep until the jobs are all complete
42
57
 
43
- JobBoss::Job.result_hash(jobs) # => {[0]=>"f", [1]=>"f", [2]=>true, [3]=>true, [4]=>"f", ... }
58
+ JobBoss::Job.result_hash(jobs) # => {[0]=>false, [1]=>false, [2]=>true, [3]=>true, [4]=>false, ... }
59
+
60
+ Features:
61
+
62
+ * Call the `cancel` method on a job to have the job boss cancel it
63
+ * 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
+ * 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
+ * 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] employee (job #4)`)
data/Rakefile CHANGED
@@ -1,15 +1,28 @@
1
- require 'job_boss'
1
+ require "rake/testtask"
2
+ require "rake/rdoctask"
2
3
 
3
- namespace :job_boss do
4
+ desc 'Default: run unit tests.'
5
+ task :default => :test
4
6
 
5
- task :start do
6
- boss = JobBoss.new
7
- boss.start
8
- end
7
+ desc 'Test the job_boss gem.'
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << 'test'
10
+ t.libs << 'test/app_root/app/jobs'
9
11
 
10
- task :stop do
11
- end
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
12
15
 
16
+ desc 'Generate documentation for the job_boss gem.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'job_boss'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ namespace :job_boss do
13
26
  task :restart do
14
27
  end
15
28
  end
data/bin/job_boss CHANGED
@@ -15,6 +15,7 @@ daemons_options = {
15
15
  Daemons.run_proc('job_boss', daemons_options) do
16
16
  Dir.chdir(working_dir)
17
17
 
18
+ $: << File.expand_path('../../lib', __FILE__)
18
19
  require 'job_boss/boss'
19
20
 
20
21
  command, daemon_options, app_options = Daemons::Controller.split_argv(ARGV)
@@ -0,0 +1,584 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: ActiveSupport::TestCase</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../test/test_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="test/test_helper.rb">test/test_helper.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Object</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-i-assert_pid_not_running">#assert_pid_not_running</a></li>
73
+
74
+ <li><a href="#method-i-assert_pid_running">#assert_pid_running</a></li>
75
+
76
+ <li><a href="#method-i-clean_app_environment">#clean_app_environment</a></li>
77
+
78
+ <li><a href="#method-i-get_pid_from_startup">#get_pid_from_startup</a></li>
79
+
80
+ <li><a href="#method-i-restart_daemon">#restart_daemon</a></li>
81
+
82
+ <li><a href="#method-i-setup_paths">#setup_paths</a></li>
83
+
84
+ <li><a href="#method-i-start_daemon">#start_daemon</a></li>
85
+
86
+ <li><a href="#method-i-stop_daemon">#stop_daemon</a></li>
87
+
88
+ <li><a href="#method-i-wait_for_file">#wait_for_file</a></li>
89
+
90
+ <li><a href="#method-i-wait_until_job_assigned">#wait_until_job_assigned</a></li>
91
+
92
+ </ul>
93
+ </div>
94
+
95
+
96
+ <!-- Included Modules -->
97
+
98
+ </div>
99
+
100
+ <div id="project-metadata">
101
+
102
+
103
+ <div id="fileindex-section" class="section project-section">
104
+ <h3 class="section-header">Files</h3>
105
+ <ul>
106
+
107
+ <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
108
+
109
+ </ul>
110
+ </div>
111
+
112
+
113
+ <div id="classindex-section" class="section project-section">
114
+ <h3 class="section-header">Class Index
115
+ <span class="search-toggle"><img src="../images/find.png"
116
+ height="16" width="16" alt="[+]"
117
+ title="show/hide quicksearch" /></span></h3>
118
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
119
+ <fieldset>
120
+ <legend>Quicksearch</legend>
121
+ <input type="text" name="quicksearch" value=""
122
+ class="quicksearch-field" />
123
+ </fieldset>
124
+ </form>
125
+
126
+ <ul class="link-list">
127
+
128
+ <li><a href="../JobBoss.html">JobBoss</a></li>
129
+
130
+ <li><a href="../JobBoss/Boss.html">JobBoss::Boss</a></li>
131
+
132
+ <li><a href="../JobBoss/Config.html">JobBoss::Config</a></li>
133
+
134
+ <li><a href="../JobBoss/Job.html">JobBoss::Job</a></li>
135
+
136
+ <li><a href="../JobBoss/Queuer.html">JobBoss::Queuer</a></li>
137
+
138
+ <li><a href="../ActiveSupport.html">ActiveSupport</a></li>
139
+
140
+ <li><a href="../ActiveSupport/TestCase.html">ActiveSupport::TestCase</a></li>
141
+
142
+ <li><a href="../CreateJobs.html">CreateJobs</a></li>
143
+
144
+ <li><a href="../DaemonTest.html">DaemonTest</a></li>
145
+
146
+ <li><a href="../MathJobs.html">MathJobs</a></li>
147
+
148
+ <li><a href="../SleepJobs.html">SleepJobs</a></li>
149
+
150
+ <li><a href="../StringJobs.html">StringJobs</a></li>
151
+
152
+ </ul>
153
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
154
+ </div>
155
+
156
+
157
+ </div>
158
+ </div>
159
+
160
+ <div id="documentation">
161
+ <h1 class="class">ActiveSupport::TestCase</h1>
162
+
163
+ <div id="description">
164
+
165
+ </div>
166
+
167
+ <!-- Constants -->
168
+
169
+
170
+ <!-- Attributes -->
171
+
172
+
173
+ <!-- Methods -->
174
+
175
+ <div id="public-instance-method-details" class="method-section section">
176
+ <h3 class="section-header">Public Instance Methods</h3>
177
+
178
+
179
+ <div id="assert-pid-not-running-method" class="method-detail ">
180
+ <a name="method-i-assert_pid_not_running"></a>
181
+
182
+ <div class="method-heading">
183
+
184
+ <span class="method-name">assert_pid_not_running</span><span
185
+ class="method-args">(pid)</span>
186
+ <span class="method-click-advice">click to toggle source</span>
187
+
188
+ </div>
189
+
190
+ <div class="method-description">
191
+
192
+
193
+
194
+
195
+
196
+ <div class="method-source-code"
197
+ id="assert-pid-not-running-source">
198
+ <pre>
199
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 35</span>
200
+ 35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_pid_not_running</span>(<span class="ruby-identifier">pid</span>)
201
+ 36: <span class="ruby-identifier">assert_raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ESRCH</span> <span class="ruby-keyword kw">do</span>
202
+ 37: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>)
203
+ 38: <span class="ruby-keyword kw">end</span>
204
+ 39: <span class="ruby-keyword kw">end</span></pre>
205
+ </div>
206
+
207
+ </div>
208
+
209
+
210
+
211
+
212
+ </div>
213
+
214
+
215
+ <div id="assert-pid-running-method" class="method-detail ">
216
+ <a name="method-i-assert_pid_running"></a>
217
+
218
+ <div class="method-heading">
219
+
220
+ <span class="method-name">assert_pid_running</span><span
221
+ class="method-args">(pid)</span>
222
+ <span class="method-click-advice">click to toggle source</span>
223
+
224
+ </div>
225
+
226
+ <div class="method-description">
227
+
228
+
229
+
230
+
231
+
232
+ <div class="method-source-code"
233
+ id="assert-pid-running-source">
234
+ <pre>
235
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 29</span>
236
+ 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-identifier">pid</span>)
237
+ 30: <span class="ruby-identifier">assert_nothing_raised</span> <span class="ruby-keyword kw">do</span>
238
+ 31: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>)
239
+ 32: <span class="ruby-keyword kw">end</span>
240
+ 33: <span class="ruby-keyword kw">end</span></pre>
241
+ </div>
242
+
243
+ </div>
244
+
245
+
246
+
247
+
248
+ </div>
249
+
250
+
251
+ <div id="clean-app-environment-method" class="method-detail ">
252
+ <a name="method-i-clean_app_environment"></a>
253
+
254
+ <div class="method-heading">
255
+
256
+ <span class="method-name">clean_app_environment</span><span
257
+ class="method-args">()</span>
258
+ <span class="method-click-advice">click to toggle source</span>
259
+
260
+ </div>
261
+
262
+ <div class="method-description">
263
+
264
+
265
+
266
+
267
+
268
+ <div class="method-source-code"
269
+ id="clean-app-environment-source">
270
+ <pre>
271
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 24</span>
272
+ 24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clean_app_environment</span>
273
+ 25: <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>) }
274
+ 26: <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>) }
275
+ 27: <span class="ruby-keyword kw">end</span></pre>
276
+ </div>
277
+
278
+ </div>
279
+
280
+
281
+
282
+
283
+ </div>
284
+
285
+
286
+ <div id="get-pid-from-startup-method" class="method-detail ">
287
+ <a name="method-i-get_pid_from_startup"></a>
288
+
289
+ <div class="method-heading">
290
+
291
+ <span class="method-name">get_pid_from_startup</span><span
292
+ class="method-args">(output)</span>
293
+ <span class="method-click-advice">click to toggle source</span>
294
+
295
+ </div>
296
+
297
+ <div class="method-description">
298
+
299
+
300
+
301
+
302
+
303
+ <div class="method-source-code"
304
+ id="get-pid-from-startup-source">
305
+ <pre>
306
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 59</span>
307
+ 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
308
+ 60: <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>
309
+ 61: <span class="ruby-keyword kw">end</span></pre>
310
+ </div>
311
+
312
+ </div>
313
+
314
+
315
+
316
+
317
+ </div>
318
+
319
+
320
+ <div id="restart-daemon-method" class="method-detail ">
321
+ <a name="method-i-restart_daemon"></a>
322
+
323
+ <div class="method-heading">
324
+
325
+ <span class="method-name">restart_daemon</span><span
326
+ class="method-args">()</span>
327
+ <span class="method-click-advice">click to toggle source</span>
328
+
329
+ </div>
330
+
331
+ <div class="method-description">
332
+
333
+
334
+
335
+
336
+
337
+ <div class="method-source-code"
338
+ id="restart-daemon-source">
339
+ <pre>
340
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 88</span>
341
+ 88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart_daemon</span>
342
+ 89: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
343
+ 90:
344
+ 91: <span class="ruby-identifier">output</span> = <span class="ruby-value">`bin/job_boss restart`</span>
345
+ 92:
346
+ 93: <span class="ruby-comment cmt"># Give the daemon a bit of time to stop</span>
347
+ 94: <span class="ruby-identifier">sleep</span>(<span class="ruby-value">0.5</span>)
348
+ 95: <span class="ruby-identifier">assert_pid_not_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
349
+ 96:
350
+ 97: <span class="ruby-ivar">@daemon_pid</span> = <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
351
+ 98:
352
+ 99: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
353
+ 100: <span class="ruby-keyword kw">end</span></pre>
354
+ </div>
355
+
356
+ </div>
357
+
358
+
359
+
360
+
361
+ </div>
362
+
363
+
364
+ <div id="setup-paths-method" class="method-detail ">
365
+ <a name="method-i-setup_paths"></a>
366
+
367
+ <div class="method-heading">
368
+
369
+ <span class="method-name">setup_paths</span><span
370
+ class="method-args">()</span>
371
+ <span class="method-click-advice">click to toggle source</span>
372
+
373
+ </div>
374
+
375
+ <div class="method-description">
376
+
377
+
378
+
379
+
380
+
381
+ <div class="method-source-code"
382
+ id="setup-paths-source">
383
+ <pre>
384
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 17</span>
385
+ 17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_paths</span>
386
+ 18: <span class="ruby-ivar">@app_root_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'test'</span>, <span class="ruby-value str">'app_root'</span>)
387
+ 19: <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>)
388
+ 20: <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>)
389
+ 21: <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>)
390
+ 22: <span class="ruby-keyword kw">end</span></pre>
391
+ </div>
392
+
393
+ </div>
394
+
395
+
396
+
397
+
398
+ </div>
399
+
400
+
401
+ <div id="start-daemon-method" class="method-detail ">
402
+ <a name="method-i-start_daemon"></a>
403
+
404
+ <div class="method-heading">
405
+
406
+ <span class="method-name">start_daemon</span><span
407
+ class="method-args">(options)</span>
408
+ <span class="method-click-advice">click to toggle source</span>
409
+
410
+ </div>
411
+
412
+ <div class="method-description">
413
+
414
+
415
+
416
+
417
+
418
+ <div class="method-source-code"
419
+ id="start-daemon-source">
420
+ <pre>
421
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 41</span>
422
+ 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_daemon</span>(<span class="ruby-identifier">options</span>)
423
+ 42: <span class="ruby-identifier">clean_app_environment</span>
424
+ 43:
425
+ 44: <span class="ruby-identifier">stop_daemon</span>
426
+ 45:
427
+ 46: <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>
428
+ 47: <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">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
429
+ 48: <span class="ruby-keyword kw">end</span>
430
+ 49:
431
+ 50: <span class="ruby-identifier">output</span> = <span class="ruby-node">`bin/job_boss start -- #{option_string.join(' ')}`</span>
432
+ 51:
433
+ 52: <span class="ruby-ivar">@daemon_pid</span> = <span class="ruby-identifier">get_pid_from_startup</span>(<span class="ruby-identifier">output</span>)
434
+ 53:
435
+ 54: <span class="ruby-identifier">assert_pid_running</span>(<span class="ruby-ivar">@daemon_pid</span>)
436
+ 55:
437
+ 56: <span class="ruby-ivar">@daemon_pid</span>
438
+ 57: <span class="ruby-keyword kw">end</span></pre>
439
+ </div>
440
+
441
+ </div>
442
+
443
+
444
+
445
+
446
+ </div>
447
+
448
+
449
+ <div id="stop-daemon-method" class="method-detail ">
450
+ <a name="method-i-stop_daemon"></a>
451
+
452
+ <div class="method-heading">
453
+
454
+ <span class="method-name">stop_daemon</span><span
455
+ class="method-args">()</span>
456
+ <span class="method-click-advice">click to toggle source</span>
457
+
458
+ </div>
459
+
460
+ <div class="method-description">
461
+
462
+
463
+
464
+
465
+
466
+ <div class="method-source-code"
467
+ id="stop-daemon-source">
468
+ <pre>
469
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 80</span>
470
+ 80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_daemon</span>
471
+ 81: <span class="ruby-value">`bin/job_boss stop`</span>
472
+ 82:
473
+ 83: <span class="ruby-comment cmt"># Give the daemon a bit of time to stop</span>
474
+ 84: <span class="ruby-identifier">sleep</span>(<span class="ruby-value">0.5</span>)
475
+ 85: <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>
476
+ 86: <span class="ruby-keyword kw">end</span></pre>
477
+ </div>
478
+
479
+ </div>
480
+
481
+
482
+
483
+
484
+ </div>
485
+
486
+
487
+ <div id="wait-for-file-method" class="method-detail ">
488
+ <a name="method-i-wait_for_file"></a>
489
+
490
+ <div class="method-heading">
491
+
492
+ <span class="method-name">wait_for_file</span><span
493
+ class="method-args">(file_path, timeout = 5)</span>
494
+ <span class="method-click-advice">click to toggle source</span>
495
+
496
+ </div>
497
+
498
+ <div class="method-description">
499
+
500
+
501
+
502
+
503
+
504
+ <div class="method-source-code"
505
+ id="wait-for-file-source">
506
+ <pre>
507
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 63</span>
508
+ 63: <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>)
509
+ 64: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
510
+ 65: <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>)
511
+ 66: <span class="ruby-identifier">sleep</span>(<span class="ruby-value">1</span>)
512
+ 67:
513
+ 68: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;File failed to appear!&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">timeout</span>
514
+ 69: <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
515
+ 70: <span class="ruby-keyword kw">end</span>
516
+ 71: <span class="ruby-keyword kw">end</span></pre>
517
+ </div>
518
+
519
+ </div>
520
+
521
+
522
+
523
+
524
+ </div>
525
+
526
+
527
+ <div id="wait-until-job-assigned-method" class="method-detail ">
528
+ <a name="method-i-wait_until_job_assigned"></a>
529
+
530
+ <div class="method-heading">
531
+
532
+ <span class="method-name">wait_until_job_assigned</span><span
533
+ class="method-args">(job, wait_interval = 0.5)</span>
534
+ <span class="method-click-advice">click to toggle source</span>
535
+
536
+ </div>
537
+
538
+ <div class="method-description">
539
+
540
+
541
+
542
+
543
+
544
+ <div class="method-source-code"
545
+ id="wait-until-job-assigned-source">
546
+ <pre>
547
+ <span class="ruby-comment cmt"># File test/test_helper.rb, line 73</span>
548
+ 73: <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>)
549
+ 74: <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">job</span>.<span class="ruby-identifier">assigned?</span>
550
+ 75: <span class="ruby-identifier">sleep</span>(<span class="ruby-identifier">wait_interval</span>)
551
+ 76: <span class="ruby-identifier">job</span>.<span class="ruby-identifier">reload</span>
552
+ 77: <span class="ruby-keyword kw">end</span>
553
+ 78: <span class="ruby-keyword kw">end</span></pre>
554
+ </div>
555
+
556
+ </div>
557
+
558
+
559
+
560
+
561
+ </div>
562
+
563
+
564
+ </div>
565
+
566
+
567
+ </div>
568
+
569
+
570
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
571
+
572
+ <p>Disabled; run with --debug to generate this.</p>
573
+
574
+ </div>
575
+
576
+ <div id="validator-badges">
577
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
578
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
579
+ Rdoc Generator</a> 1.1.6</small>.</p>
580
+ </div>
581
+
582
+ </body>
583
+ </html>
584
+