From 5cd823847b37c66d521545180c81d9a92ca0ab57 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Dec 2012 11:18:38 +0200 Subject: [PATCH] Use gitlab resque fork. Added rake task to stop all workers --- Gemfile | 2 +- Gemfile.lock | 22 +++++++++++----------- lib/tasks/resque.rake | 19 +++++++++++++++++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 58a8ff55..7539132d 100644 --- a/Gemfile +++ b/Gemfile @@ -77,7 +77,7 @@ gem "acts-as-taggable-on", "2.3.3" gem "draper", "~> 0.18.0" # Background jobs -gem "resque", git: "https://github.com/defunkt/resque.git", ref: "9ef4700306dd946a3ac000612428967ce0c32213" +gem "resque", git: "https://github.com/gitlabhq/resque.git", ref: "9ef4700306dd946a3ac000612428967ce0c32213" gem 'resque_mailer' # HTTP requests diff --git a/Gemfile.lock b/Gemfile.lock index 67d4f576..fd543191 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,17 +13,6 @@ GIT activerecord (>= 2.3.0) rake (>= 0.8.7) -GIT - remote: https://github.com/defunkt/resque.git - revision: 9ef4700306dd946a3ac000612428967ce0c32213 - ref: 9ef4700306dd946a3ac000612428967ce0c32213 - specs: - resque (2.0.0.pre.1) - json - redis-namespace (~> 1.0) - sinatra (>= 0.9.2) - vegas (~> 0.1.2) - GIT remote: https://github.com/gitlabhq/grack.git revision: ba46f3b0845c6a09d488ae6abdce6ede37e227e8 @@ -70,6 +59,17 @@ GIT posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) +GIT + remote: https://github.com/gitlabhq/resque.git + revision: 9ef4700306dd946a3ac000612428967ce0c32213 + ref: 9ef4700306dd946a3ac000612428967ce0c32213 + specs: + resque (2.0.0.pre.1) + json + redis-namespace (~> 1.0) + sinatra (>= 0.9.2) + vegas (~> 0.1.2) + GIT remote: https://github.com/gitlabhq/yaml_db.git revision: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake index 36e461da..0c3b93c5 100644 --- a/lib/tasks/resque.rake +++ b/lib/tasks/resque.rake @@ -1,7 +1,22 @@ require 'resque/tasks' -task "resque:setup" => :environment do - Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } +namespace :resque do + task setup: :environment do + Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } + end + + desc "Resque | kill all workers (using -QUIT), god will take care of them" + task :stop_workers => :environment do + pids = Array.new + + Resque.workers.each do |worker| + pids << worker.to_s.split(/:/).second + end + + if pids.size > 0 + system("kill -QUIT #{pids.join(' ')}") + end + end end desc "Alias for resque:work (To run workers on Heroku)"