RQ::MainHelper (Class)

In: lib/rq-2.3.1/mainhelper.rb
Parent: Object
MainHelper StatusLister Snapshotter ReSubmitter Feeder Deleter Relayer Executor Submitter Locker Backer Configurator Lister Rotater Creator Updater Querier ::Hash ConfigFile DRbUndumped JobRunner Main QDB JobQueue JobRunnerDaemon Array SleepCycle Job ArrayFields ::OrderedHash OrderedAutoHash LogMethods Refresher lib/rq-2.3.1/rotater.rb lib/rq-2.3.1/sleepcycle.rb lib/rq-2.3.1/statuslister.rb lib/rq-2.3.1/updater.rb lib/rq-2.3.1/relayer.rb lib/rq-2.3.1/creator.rb lib/rq-2.3.1/lister.rb lib/rq-2.3.1/snapshotter.rb bin/rq.rb lib/rq-2.3.1/resubmitter.rb lib/rq-2.3.1/orderedautohash.rb lib/rq-2.3.1/locker.rb lib/rq-2.3.1/querier.rb lib/rq-2.3.1/submitter.rb lib/rq-2.3.1/configfile.rb lib/rq-2.3.1/executor.rb lib/rq-2.3.1/refresher.rb lib/rq-2.3.1/job.rb lib/rq-2.3.1/mainhelper.rb lib/rq-2.3.1/qdb.rb lib/rq-2.3.1/feeder.rb lib/rq-2.3.1/configurator.rb lib/rq-2.3.1/deleter.rb lib/rq-2.3.1/jobqueue.rb lib/rq-2.3.1/jobrunnerdaemon.rb lib/rq-2.3.1/backer.rb lib/rq-2.3.1/jobrunner.rb Usage Util LogClassMethods LoggerExt LogMethods Logging RQ Module: RQ

the MainHelper class abstracts some of the common functions the various Main delegates require

Methods

loadio   new   set_q  

Attributes

argv  [R] 
cmd  [R] 
env  [R] 
main  [R] 
mode  [R] 
options  [R] 
q  [R] 
qpath  [R] 

Included Modules

Util Logging

Public Class methods

[Source]

    # File lib/rq-2.3.1/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

Public Instance methods

[Source]

    # File lib/rq-2.3.1/mainhelper.rb, line 51
51:       def loadio io, path, jobs
52: #--{{{
53:         while((line = io.gets))
54:           if line =~ %/^---\s*$/o
55:             loaded = YAML::load io 
56:             raise "no jobs in <#{ path }>" unless 
57:               Array === loaded and 
58:               Hash === loaded.first and Hash === loaded.last
59:             loaded.each{|job| jobs << job}
60:             loaded = nil
61:           else
62:             line.gsub!(%/(?:^\s+)|(?:\s+$)|(?:#.*$)/o, '')
63:             next if line.empty?
64:             job = Job::new
65:             if((m =  %/^\s*(?:jid\s*=\s*)?(\d+)\s*$/io.match(line)))
66:               job['jid'] = Integer(m[1])
67:             else
68:               job['command'] = line
69:             end
70:             jobs << job
71:           end
72:         end
73: #--}}}
74:       end

[Source]

    # File lib/rq-2.3.1/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

[Validate]