Sha256: ec4e533d078aefc6f0cd02fab7fb40cda07a9d0ddf78b53bcec8ddba5d8992c7
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'sidekiq' require 'cli' require 'version' class SidekiqClientCLI COMMANDS = %w{push} DEFAULT_CONFIG_PATH = "config/initializers/sidekiq.rb" attr_accessor :settings def initialize end def parse @settings = CLI.new do option :config_path, :short => :c, :default => DEFAULT_CONFIG_PATH, :description => "Sidekiq client config file path" argument :command, :description => "'push' to push a job to the queue" arguments :command_args, :required => false, :description => "command arguments" end.parse! do |settings| fail "Invalid command '#{settings.command}'. Available commands: #{COMMANDS.join(',').chomp(',')}" unless COMMANDS.include? settings.command if settings.command == "push" && settings.command_args.empty? fail "No Worker Classes to push" end end end def run # load the config file load settings.config_path if File.exists? settings.config_path self.send settings.command.to_sym end def push settings.command_args.each do |arg| begin jid = Sidekiq::Client.push('class' => arg, 'args' => []) p "Posted #{arg} to queue, Job ID : #{jid}" rescue StandardError => ex p "Failed to push to queue : #{ex.message}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-client-cli-0.0.1 | lib/sidekiq_client_cli.rb |