Class: Delayed::Master::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/delayed/master/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Command

Returns a new instance of Command.



11
12
13
14
15
16
17
18
19
20
21
22
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
49
50
51
52
# File 'lib/delayed/master/command.rb', line 11

def initialize(args)
  @config = Config.new

  OptionParser.new { |opt|
    opt.banner = <<-EOS
      #{File.basename($PROGRAM_NAME)} #{DelayedJobMaster::VERSION}
      Usage: #{File.basename($PROGRAM_NAME)} [options]
    EOS

    opt.on('-h', '--help', '-v', '--version', 'Show this message') do |boolean|
      puts opt
      exit
    end
    opt.on('-c', '--config=FILE', 'Specify config file') do |file|
      @config.read(file)
    end
    opt.on('-D', '--daemon', 'Start master as a daemon') do |boolean|
      @config.daemon = boolean
    end
    opt.on('--working-directory=DIR', 'Path to working directory') do |dir|
      @config.working_directory = dir
    end
    opt.on('--pid-file=FILE', 'Path to pid file') do |file|
      @config.pid_file = file
    end
    opt.on('--log-file=FILE', 'Path to log file') do |file|
      @config.log_file = file
    end
    opt.on('--log-level=LEVEL', 'Log level') do |level|
      @config.log_level = level.to_sym
    end
    opt.on('--monitor-interval=INTERVAL', Numeric, 'Monitor interval') do |interval|
      @config.monitor_interval = interval
    end
    opt.on('--polling-interval=INTERVAL', Numeric, 'Polling interval') do |interval|
      @config.polling_interval = interval
    end
    opt.on('--databases=DB1,DB2', Array, 'Database spec name to check delayed_jobs table') do |databases|
      @config.databases = databases.map(&:to_sym)
    end
  }.parse(args)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/delayed/master/command.rb', line 9

def config
  @config
end