Sha256: ced5a35d010016654ba97c1d8add9b74dd83461bfb6b97b247d0e41b1c235a4c

Contents?: true

Size: 1.06 KB

Versions: 47

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.mongo = 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 mongo_host:mongo_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

47 entries across 47 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.7.4 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.7.3 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.7.2 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.7.1 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.7.0 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.9 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.8 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.7 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.6 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.5 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.4 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.3 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.2 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.1 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.6.0 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.5.17 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.5.16 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.5.15 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque
classiccms-0.5.14 vendor/bundle/gems/resque-mongo-1.9.8.1/bin/resque