Created
May 5, 2010 20:37
-
-
Save jhsu/391387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
count: 1 | |
queue: "*" | |
qa: | |
count: 2 | |
queue: "*" | |
demo: | |
count: 2 | |
queue: "*" | |
staging: | |
count: 2 | |
queue: "*" | |
production: | |
count: 4 | |
queue: "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# This script handles starting and stopping of resque workers | |
require File.dirname(__FILE__) + '/../config/environment' | |
require 'yaml' | |
rails_root = File.dirname(__FILE__) + '/..' | |
rails_env = ENV['RAILS_ENV'] || 'development' | |
worker_config = YAML.load_file(rails_root + '/config/resque_work.yml')[rails_env] | |
begin | |
case ARGV[0] | |
when 'start' | |
count = worker_config['count'] || 1 | |
puts "#{count} workers being started" | |
count.times do | |
puts "Worker started." if Resque::Worker.new(worker_config['queue']).startup | |
end | |
puts "#{Resque.workers.length} workers running" | |
when 'stop' | |
workers = Resque.workers | |
puts "#{workers.length} workers running" | |
workers.each do |worker| | |
worker.shutdown! | |
worker.unregister_worker | |
end | |
puts "#{Resque.workers.length} workers running" | |
when 'run' | |
else | |
puts "usage: start|stop|run" | |
end | |
rescue => e | |
HoptoadNotifier.notify(e) | |
raise | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment