| In: |
lib/rq-2.0.0/mainhelper.rb
|
| Parent: | Object |
the MainHelper class abstracts some of the common functions the various Main delegates require
| argv | [R] | |
| cmd | [R] | |
| env | [R] | |
| main | [R] | |
| mode | [R] | |
| options | [R] | |
| q | [R] | |
| qpath | [R] |
# File lib/rq-2.0.0/mainhelper.rb, line 26
26: def initialize main
27: #--{{{
28: @main = main
29: @logger = main.logger
30: @argv = main.argv
31: @env = main.env
32: @cmd = main.cmd
33: @options = main.options
34: @qpath = main.qpath
35: @mode = main.mode
36: @q = nil
37: #--}}}
38: end
# File lib/rq-2.0.0/mainhelper.rb, line 39
39: def set_q
40: #--{{{
41: raise "q <#{ @qpath }> does not exist" unless test ?d, @qpath
42: @q = JobQueue::new @qpath, 'logger' => @logger
43: if @options['snapshot']
44: ss = "#{ $0 }_#{ Process::pid }_#{ Thread::current.id.abs }_#{ rand Time::now.to_i }".gsub(%|/|o,'_')
45: qtmp = File::join Dir::tmpdir, ss
46: @q = @q.snapshot qtmp, @options['retries']
47: at_exit{ FileUtils::rm_rf qtmp }
48: end
49: #--}}}
50: end