Method: Cron::Command#initialize

Defined in:
lib/app/jobs/cron/command.rb

#initialize(args) ⇒ Command

Initialize the command



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
# File 'lib/app/jobs/cron/command.rb', line 20

def initialize(args)
  @options = { pid_dir: "#{root}/tmp/pids", log_dir: "#{root}/log", monitor: false }

  opts = OptionParser.new do |opt|
    opt.banner = "Usage: #{File.basename($PROGRAM_NAME)} [options] start|stop|restart|run"

    opt.on('-h', '--help', 'Show this message') do
      warn opt
      exit 1
    end
    opt.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
      @options[:pid_dir] = dir
    end
    opt.on('--log-dir=DIR', 'Specifies an alternate directory in which to store the delayed_job log.') do |dir|
      @options[:log_dir] = dir
    end
    opt.on('-m', '--monitor', 'Start monitor process.') do
      @options[:monitor] = true
    end
    opt.on('--exit-on-complete', 'Exit when no more jobs are available to run.') do
      @options[:exit_on_complete] = true
    end
    opt.on('--daemon-options a, b, c', Array, 'options to be passed through to daemons gem') do |daemon_options|
      @daemon_options = daemon_options
    end
  end
  @args = opts.parse!(args) + (@daemon_options || [])
end