Class: RQ::Creator

Inherits:
MainHelper show all
Defined in:
lib/rq/creator.rb

Overview

a queue is a directory

the Creator class is responsible for initializing the queue directory and all supporting files. these include:

  • the sqlite database (binary)

  • the sqlite database schema description file (text)

  • the empty sentinel file used for locking (text - empty)

it is an error to attempt to initialize a queue which already exists

Constant Summary

Constants included from Logging

Logging::DIV0, Logging::DIV1, Logging::DIV2, Logging::DIV3, Logging::EOL, Logging::SEC0, Logging::SEC1, Logging::SEC2, Logging::SEC3

Instance Attribute Summary

Attributes inherited from MainHelper

#argv, #cmd, #dot_rq_dir, #env, #fields, #job_stdin, #loops, #main, #mode, #options, #program, #q, #qpath, #quiet, #stdin

Instance Method Summary collapse

Methods inherited from MainHelper

#dumping_yaml_tuples, #field_match, #init_job_stdin!, #initialize, #loadio, #loadyaml, #set_q

Methods included from Logging

append_features

Methods included from Logging::LogMethods

#debug, #error, #fatal, #info, #logerr, #logger, #logger=, #warn

Methods included from Util

#alive?, append_features, #btrace, #columnize, #defval, #emsg, #erreq, #errmsg, #escape, #escape!, #exec, export, #fork, #getopt, #hashify, #hms, #host, #hostname, #klass, #maim, #mcp, #realpath, #stamptime, #system, #timestamp, #tmpnam, #uncache, #which_ruby

Constructor Details

This class inherits a constructor from RQ::MainHelper

Instance Method Details

#createObject

–{{{



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rq/creator.rb', line 23

def create 
#--{{{
  raise "q <#{ @qpath }> exists!" if test ?e, @qpath
  @q = JobQueue::create @qpath, 'logger' => @logger

  unless quiet?
    puts '---'
    puts "q: #{ @q.path }"
    puts "db: #{ @q.db.path }"
    puts "schema: #{ @q.db.schema }"
    puts "lock: #{ @q.db.lockfile }"
    puts "bin: #{ @q.bin }"
    puts "stdin: #{ @q.stdin }"
    puts "stdout: #{ @q.stdout }"
    puts "stderr: #{ @q.stderr }"
    puts "data: #{ @q.data }"
  end

  rqmailer = File.join(File.dirname(@program), 'rqmailer')
  if test ?e, rqmailer
    FileUtils.cp rqmailer, @q.bin
  end

  self
#--}}}
end