Commit 5cd823847b37c66d521545180c81d9a92ca0ab57

Authored by Dmitriy Zaporozhets
1 parent 3b1519da

Use gitlab resque fork. Added rake task to stop all workers

Showing 3 changed files with 29 additions and 14 deletions   Show diff stats
@@ -77,7 +77,7 @@ gem "acts-as-taggable-on", "2.3.3" @@ -77,7 +77,7 @@ gem "acts-as-taggable-on", "2.3.3"
77 gem "draper", "~> 0.18.0" 77 gem "draper", "~> 0.18.0"
78 78
79 # Background jobs 79 # Background jobs
80 -gem "resque", git: "https://github.com/defunkt/resque.git", ref: "9ef4700306dd946a3ac000612428967ce0c32213" 80 +gem "resque", git: "https://github.com/gitlabhq/resque.git", ref: "9ef4700306dd946a3ac000612428967ce0c32213"
81 gem 'resque_mailer' 81 gem 'resque_mailer'
82 82
83 # HTTP requests 83 # HTTP requests
@@ -14,17 +14,6 @@ GIT @@ -14,17 +14,6 @@ GIT
14 rake (>= 0.8.7) 14 rake (>= 0.8.7)
15 15
16 GIT 16 GIT
17 - remote: https://github.com/defunkt/resque.git  
18 - revision: 9ef4700306dd946a3ac000612428967ce0c32213  
19 - ref: 9ef4700306dd946a3ac000612428967ce0c32213  
20 - specs:  
21 - resque (2.0.0.pre.1)  
22 - json  
23 - redis-namespace (~> 1.0)  
24 - sinatra (>= 0.9.2)  
25 - vegas (~> 0.1.2)  
26 -  
27 -GIT  
28 remote: https://github.com/gitlabhq/grack.git 17 remote: https://github.com/gitlabhq/grack.git
29 revision: ba46f3b0845c6a09d488ae6abdce6ede37e227e8 18 revision: ba46f3b0845c6a09d488ae6abdce6ede37e227e8
30 ref: ba46f3b0845c6a09d488ae6abdce6ede37e227e8 19 ref: ba46f3b0845c6a09d488ae6abdce6ede37e227e8
@@ -71,6 +60,17 @@ GIT @@ -71,6 +60,17 @@ GIT
71 yajl-ruby (~> 1.1.0) 60 yajl-ruby (~> 1.1.0)
72 61
73 GIT 62 GIT
  63 + remote: https://github.com/gitlabhq/resque.git
  64 + revision: 9ef4700306dd946a3ac000612428967ce0c32213
  65 + ref: 9ef4700306dd946a3ac000612428967ce0c32213
  66 + specs:
  67 + resque (2.0.0.pre.1)
  68 + json
  69 + redis-namespace (~> 1.0)
  70 + sinatra (>= 0.9.2)
  71 + vegas (~> 0.1.2)
  72 +
  73 +GIT
74 remote: https://github.com/gitlabhq/yaml_db.git 74 remote: https://github.com/gitlabhq/yaml_db.git
75 revision: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd 75 revision: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd
76 ref: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd 76 ref: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd
lib/tasks/resque.rake
1 require 'resque/tasks' 1 require 'resque/tasks'
2 2
3 -task "resque:setup" => :environment do  
4 - Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } 3 +namespace :resque do
  4 + task setup: :environment do
  5 + Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
  6 + end
  7 +
  8 + desc "Resque | kill all workers (using -QUIT), god will take care of them"
  9 + task :stop_workers => :environment do
  10 + pids = Array.new
  11 +
  12 + Resque.workers.each do |worker|
  13 + pids << worker.to_s.split(/:/).second
  14 + end
  15 +
  16 + if pids.size > 0
  17 + system("kill -QUIT #{pids.join(' ')}")
  18 + end
  19 + end
5 end 20 end
6 21
7 desc "Alias for resque:work (To run workers on Heroku)" 22 desc "Alias for resque:work (To run workers on Heroku)"