#!/usr/bin/env ruby require 'rubygems' require 'thor' require 'aws-sdk-core' require_relative 'cli/base' require_relative 'cli/sqs' require_relative '../lib/shoryuken/runner' # rubocop:disable Metrics/AbcSize module Shoryuken module CLI class Runner < Base default_task :start register(Shoryuken::CLI::SQS, 'sqs', 'sqs COMMAND', 'SQS commands') desc 'start', 'Starts 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 :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 :config_file, type: :string, desc: 'Path to config file (backwards compatibility)' 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' method_option :delay, aliases: '-D', type: :numeric, desc: 'Number of seconds to pause fetching from an empty queue' def start opts = options.to_h.symbolize_keys if opts[:config_file] say "[DEPRECATED] Please use --config instead of --config-file", :yellow end opts[:config_file] = opts.delete(:config) if opts[:config] # Keep compatibility with old CLI queue format opts[:queues] = options[:queues].map { |q| q.split(',') } if options[:queues] if options[:daemon] && options[:logfile].nil? fail_task "You should set a logfile if you're going to daemonize" end Shoryuken::Runner.instance.run(opts.freeze) end desc 'version', 'Prints version' def version say "Shoryuken #{Shoryuken::VERSION}" end end end end Shoryuken::CLI::Runner.start