Sha256: 7b3cf459a495cd63c6494889b2c6becbdf10127f9c18b23fad995a2309533188

Contents?: true

Size: 1.79 KB

Versions: 5

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require 'optparse'
require_relative 'config'

module Delayed
  module Master
    class Command
      attr_reader :config

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
delayed_job_master-3.1.2 lib/delayed/master/command.rb
delayed_job_master-3.1.1 lib/delayed/master/command.rb
delayed_job_master-3.1.0 lib/delayed/master/command.rb
delayed_job_master-3.0.1 lib/delayed/master/command.rb
delayed_job_master-3.0.0 lib/delayed/master/command.rb