summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-26 11:18:38 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-26 11:23:43 +0200
commit5cd823847b37c66d521545180c81d9a92ca0ab57 (patch)
tree000af447438a6350f54e0bb9440f251c93326401 /lib
parent3b1519da477dd0fd4264d180b35109e8ec904e33 (diff)
downloadgitlab-ce-5cd823847b37c66d521545180c81d9a92ca0ab57.tar.gz
Use gitlab resque fork. Added rake task to stop all workers
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/resque.rake19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake
index 36e461da660..0c3b93c5bed 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)"