Skip to content

Commit

Permalink
Merge 7f25661 into 73bd1b5
Browse files Browse the repository at this point in the history
  • Loading branch information
utilum committed Jun 30, 2018
2 parents 73bd1b5 + 7f25661 commit 0c758c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/delayed/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def initialize(args) # rubocop:disable MethodLength

@worker_count = 1
@monitor = false
@args = nil
@daemon_options = nil

opts = OptionParser.new do |opt|
opt.banner = "Usage: #{File.basename($PROGRAM_NAME)} [options] start|stop|restart|run"
Expand Down
17 changes: 12 additions & 5 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'active_support/dependencies'
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/module/redefine_method'
require 'active_support/hash_with_indifferent_access'
require 'active_support/core_ext/hash/indifferent_access'
require 'logger'
Expand All @@ -19,10 +20,13 @@ class Worker # rubocop:disable ClassLength
DEFAULT_QUEUE_ATTRIBUTES = HashWithIndifferentAccess.new.freeze
DEFAULT_READ_AHEAD = 5

cattr_accessor :min_priority, :max_priority, :max_attempts, :max_run_time,
:default_priority, :sleep_delay, :logger, :delay_jobs, :queues,
:read_ahead, :plugins, :destroy_failed_jobs, :exit_on_complete,
:default_log_level
cattr_accessor :min_priority, :max_priority, :default_priority, :sleep_delay,
:logger, :delay_jobs, :queues, :read_ahead, :plugins,
:destroy_failed_jobs, :exit_on_complete, :default_log_level

class << self
attr_accessor :max_attempts, :max_run_time
end

# Named queue into which jobs are enqueued by default
cattr_accessor :default_queue_name
Expand All @@ -31,6 +35,7 @@ class Worker # rubocop:disable ClassLength

# name_prefix is ignored if name is set directly
attr_accessor :name_prefix
attr_writer :max_attempts, :max_run_time

def self.reset
self.default_log_level = DEFAULT_LOG_LEVEL
Expand Down Expand Up @@ -130,6 +135,8 @@ def self.delay_job?(job)
def initialize(options = {})
@quiet = options.key?(:quiet) ? options[:quiet] : true
@failed_reserve_count = 0
@name_prefix = nil
@exit = nil

[:min_priority, :max_priority, :sleep_delay, :read_ahead, :queues, :exit_on_complete].each do |option|
self.class.send("#{option}=", options[option]) if options.key?(option)
Expand All @@ -145,7 +152,7 @@ def initialize(options = {})
# safely resume working on tasks which are locked by themselves. The worker will assume that
# it crashed before.
def name
return @name unless @name.nil?
return @name if defined?(@name)
"#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}" rescue "#{@name_prefix}pid:#{Process.pid}"
end

Expand Down
1 change: 0 additions & 1 deletion spec/delayed/backend/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Delayed
module Backend
module Test
class Job
attr_accessor :id
attr_accessor :priority
attr_accessor :attempts
attr_accessor :handler
Expand Down
3 changes: 0 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
end
ENV['RAILS_ENV'] = 'test'

# Trigger AR to initialize
ActiveRecord::Base # rubocop:disable Void

module Rails
def self.root
'.'
Expand Down

0 comments on commit 0c758c6

Please sign in to comment.