├── LICENSE ├── README.md └── bin └── resque /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Chris Wanstrath 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | resque-cli 2 | ========== 3 | 4 | This is a work-in-progress extraction from [Resque][rq]. The goal is 5 | to make this a standalone gem and, once development has settled down, 6 | include it with Resque. 7 | 8 | [rq]: http://github.com/defunkt/resque 9 | -------------------------------------------------------------------------------- /bin/resque: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'resque' 4 | 5 | def kill(worker) 6 | abort "** resque kill WORKER_ID" if worker.nil? 7 | pid = worker.split(':')[1].to_i 8 | 9 | begin 10 | Process.kill("KILL", pid) 11 | puts "** killed #{worker}" 12 | rescue Errno::ESRCH 13 | puts "** worker #{worker} not running" 14 | end 15 | 16 | remove worker 17 | end 18 | 19 | def remove(worker) 20 | abort "** resque remove WORKER_ID" if worker.nil? 21 | 22 | Resque.remove_worker(worker) 23 | puts "** removed #{worker}" 24 | end 25 | 26 | def list 27 | if Resque.workers.any? 28 | Resque.workers.each do |worker| 29 | puts "#{worker} (#{worker.state})" 30 | end 31 | else 32 | puts "None" 33 | end 34 | end 35 | 36 | if (i = ARGV.index('-r')) && ARGV[i+1] 37 | Resque.redis = ARGV[i+1] 38 | ARGV.delete_at(i) 39 | ARGV.delete_at(i+1) 40 | end 41 | 42 | case ARGV[0] 43 | when 'kill' 44 | kill ARGV[1] 45 | when 'remove' 46 | remove ARGV[1] 47 | when 'list' 48 | list 49 | else 50 | puts "Usage: resque [-r redis_host:redis_port] COMMAND [option]" 51 | puts 52 | puts "Commands:" 53 | puts " remove WORKER Removes a worker" 54 | puts " kill WORKER Kills a worker" 55 | puts " list Lists known workers" 56 | end 57 | --------------------------------------------------------------------------------