Permalink
Browse files

first post

  • Loading branch information...
0 parents commit ac0866af4675422110b4f594b321edb06bb79b47 @defunkt committed Mar 26, 2010
Showing with 84 additions and 0 deletions.
  1. +20 −0 LICENSE
  2. +8 −0 README.md
  3. +56 −0 bin/resque
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Chris Wanstrath
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 README.md
@@ -0,0 +1,8 @@
+resque-cli
+==========
+
+This is a work-in-progress extraction from [Resque][rq]. The goal is
+to make this a standalone gem and, once development has settled down,
+include it with Resque.
+
+[rq]: http://github.com/defunkt/resque
56 bin/resque
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+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

0 comments on commit ac0866a

Please sign in to comment.