Sha256: c6831cc6cc7b460b3911e9f2fe16beb44b8add4aa6d62bb561785791b9de0995

Contents?: true

Size: 1.55 KB

Versions: 99

Compression:

Stored size: 1.55 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
begin
  require 'redis-namespace'
rescue LoadError
  require 'rubygems'
  require 'redis-namespace'
end
require 'resque'
require 'optparse'

parser = OptionParser.new do |opts|
  opts.banner = "Usage: resque [options] COMMAND"

  opts.separator ""
  opts.separator "Options:"

  opts.on("-r", "--redis [HOST:PORT]", "Redis connection string") do |host|
    Resque.redis = host
  end

  opts.on("-N", "--namespace [NAMESPACE]", "Redis namespace") do |namespace|
    Resque.redis.namespace = namespace
  end

  opts.on("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.separator ""
  opts.separator "Commands:"
  opts.separator "  remove WORKER   Removes a worker"
  opts.separator "  kill WORKER     Kills a worker"
  opts.separator "  list            Lists known workers"
end

def kill(worker)
  abort "** resque kill WORKER_ID" if worker.nil?
  pid = worker.split(':')[1].to_i

  begin
    Process.kill("KILL", pid)
    puts "** killed #{worker}"
  rescue Errno::ESRCH
    puts "** worker #{worker} not running"
  end

  remove worker
end

def remove(worker)
  abort "** resque remove WORKER_ID" if worker.nil?

  Resque.remove_worker(worker)
  puts "** removed #{worker}"
end

def list
  if Resque.workers.any?
    Resque.workers.each do |worker|
      puts "#{worker} (#{worker.state})"
    end
  else
    puts "None"
  end
end

parser.parse!

case ARGV[0]
when 'kill'
  kill ARGV[1]
when 'remove'
  remove ARGV[1]
when 'list'
  list
else
  puts parser.help
end

Version data entries

99 entries across 99 versions & 12 rubygems

Version Path
classiccms-0.6.5 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.6.4 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.6.3 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.6.2 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.6.1 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.6.0 vendor/bundle/gems/resque-1.20.0/bin/resque
resque-1.23.0 bin/resque
classiccms-0.5.17 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.16 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.15 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.14 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.13 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.12 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.11 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.10 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.9 vendor/bundle/gems/resque-1.20.0/bin/resque
resque-1.22.0 bin/resque
classiccms-0.5.8 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.7 vendor/bundle/gems/resque-1.20.0/bin/resque
classiccms-0.5.6 vendor/bundle/gems/resque-1.20.0/bin/resque