Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow identifier with multiple workers #1190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/delayed/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,17 @@ def initialize(args) # rubocop:disable MethodLength
@args = opts.parse!(args) + (@daemon_options || [])
end

def daemonize # rubocop:disable PerceivedComplexity
def daemonize
dir = @options[:pid_dir]
FileUtils.mkdir_p(dir) unless File.exist?(dir)

if worker_pools
setup_pools
elsif @options[:identifier]
# rubocop:disable GuardClause
if worker_count > 1
raise ArgumentError, 'Cannot specify both --number-of-workers and --identifier'
else
run_process("delayed_job.#{@options[:identifier]}", @options)
end
# rubocop:enable GuardClause
else
worker_count.times do |worker_index|
process_name = worker_count == 1 ? 'delayed_job' : "delayed_job.#{worker_index}"
process_name = 'delayed_job'
process_name += ".#{@options[:identifier]}" if @options[:identifier]
process_name += ".#{worker_index}" if worker_count > 1
run_process(process_name, @options)
end
end
Expand Down