Sha256: 2ac865616b4f9ddd717789bd107bce27887d9d42bfafc1187c381450557c317f

Contents?: true

Size: 1.06 KB

Versions: 53

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'resque'

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

if (i = ARGV.index('-r')) && ARGV[i+1]
  Resque.redis = ARGV[i+1]
  ARGV.delete_at(i)
  ARGV.delete_at(i+1)
end

case ARGV[0]
when 'kill'
  kill ARGV[1]
when 'remove'
  remove ARGV[1]
when 'list'
  list
else
  puts "Usage: resque [-r redis_host:redis_port] COMMAND [option]"
  puts
  puts "Commands:"
  puts "  remove WORKER   Removes a worker"
  puts "  kill WORKER     Kills a worker"
  puts "  list            Lists known workers"
end

Version data entries

53 entries across 53 versions & 6 rubygems

Version Path
resque-1.11.0 bin/resque
resque-1.12.0 bin/resque
resque-igo-1.12.2 bin/resque
resque-igo-1.12.1 bin/resque
resque-igo-1.1.5 bin/resque
resque-igo-1.1.4 bin/resque
resque-igo-1.1.3 bin/resque
resque-igo-1.1.2 bin/resque
resque-igo-1.1.1 bin/resque
resque-igo-1.1 bin/resque
resque-1.10.0 bin/resque
resque-1.9.10 bin/resque
resque-1.9.9 bin/resque
resque-1.9.8 bin/resque
resque-1.9.7 bin/resque
resque-1.9.5 bin/resque
resque-1.9.4 bin/resque
resque-1.9.3 bin/resque
resque-1.9.2 bin/resque
resque-1.9.1 bin/resque