diff --git a/bin/shoryuken b/bin/shoryuken index 6d44aed8..513ad98e 100755 --- a/bin/shoryuken +++ b/bin/shoryuken @@ -19,7 +19,7 @@ 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' @@ -27,15 +27,16 @@ module Shoryuken 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' diff --git a/lib/shoryuken/environment_loader.rb b/lib/shoryuken/environment_loader.rb index 502f57d9..44d26c1f 100644 --- a/lib/shoryuken/environment_loader.rb +++ b/lib/shoryuken/environment_loader.rb @@ -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