Skip to content

Commit

Permalink
Fix CLI compatibility with old CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Cantero committed Mar 11, 2017
1 parent 54d9cfc commit c96f218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
17 changes: 9 additions & 8 deletions bin/shoryuken
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ module Shoryuken
desc 'start', 'Start shoryuken'
method_option :concurrency, aliases: '-c', type: :numeric, desc: 'Processor threads to use'
method_option :daemon, aliases: '-d', type: :boolean, desc: 'Daemonize process'
method_option :queue, aliases: '-q', type: :string, desc: 'Queues to process with optional weights'
method_option :queues, aliases: '-q', type: :array, desc: 'Queues to process with optional weights'
method_option :require, aliases: '-r', type: :string, desc: 'Dir or path of the workers'
method_option :config, aliases: '-C', type: :string, desc: 'Path to config file'
method_option :rails, aliases: '-R', type: :boolean, desc: 'Load Rails'
method_option :logfile, aliases: '-L', type: :string, desc: 'Path to logfile'
method_option :pidfile, aliases: '-P', type: :string, desc: 'Path to pidfile'
method_option :verbose, aliases: '-v', type: :boolean, desc: 'Print more verbose output'
def start
if options[:queue]
queue, weight = options[:queue].split(',')
options[:queues] = [] unless options[:queues]
options[:queues] << [queue, weight]
end
opts = options.to_h.symbolize_keys

# Keep compatibility with old CLI queue format
opts[:queues] = opts[:queues].to_a.map { |q| q.split(',') }

fail_task "You should set a logfile if you're going to daemonize" unless options[:logfile]
if opts[:daemon] && opts[:logfile].nil?
fail_task "You should set a logfile if you're going to daemonize"
end

Shoryuken::Runner.instance.run(options.to_h)
Shoryuken::Runner.instance.run(opts.freeze)
end

desc 'version', 'Print version'
Expand Down
7 changes: 3 additions & 4 deletions lib/shoryuken/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ def load_rails
end

def merge_cli_defined_queues
cli_defined_queues = options.delete(:queues) || []
cli_defined_queues = options[:queues]

cli_defined_queues.each do |cli_defined_queue|
Shoryuken.options[:queues].delete_if do |config_file_queue|
config_file_queue[0] == cli_defined_queue[0]
end
# CLI defined queues override config_file defined queues
Shoryuken.options[:queues].delete_if { |config_file_queue| config_file_queue[0] == cli_defined_queue[0] }

Shoryuken.options[:queues] << cli_defined_queue
end
Expand Down

0 comments on commit c96f218

Please sign in to comment.