diff --git a/Gemfile.lock b/Gemfile.lock index b8f00f6bd..a186dc444 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -320,7 +320,7 @@ GEM rdoc (3.12.2) json (~> 1.4) redcarpet (2.2.2) - redis (3.0.6) + redis (3.0.7) redis-actionpack (3.2.4) actionpack (~> 3.2.0) redis-rack (~> 1.4.4) @@ -349,7 +349,7 @@ GEM redis-namespace (~> 1.2) sinatra (>= 0.9.2) vegas (~> 0.1.2) - resque-scheduler (2.5.3) + resque-scheduler (2.5.4) redis (~> 3.0.4) resque (~> 1.25.1) rufus-scheduler (~> 2.0.24) diff --git a/Rakefile b/Rakefile index 05eb30807..562c9b3d7 100644 --- a/Rakefile +++ b/Rakefile @@ -6,13 +6,4 @@ require 'rake' require 'resque/tasks' require 'resque_scheduler/tasks' -# This fixes connection fail with Postgres server on new fork: -task "resque:setup" => :environment do - Resque.after_fork do - Resque.redis.client.reconnect - # Resque.schedule = YAML.load_file(File.join(Rails.root, 'config/resque_schedule.yml')) # load the schedule - end - Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } -end - Rosa::Application.load_tasks diff --git a/app/models/build_list.rb b/app/models/build_list.rb index ad743266f..78976b241 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -527,19 +527,17 @@ class BuildList < ActiveRecord::Base end def self.next_build - unless task = (Resque.pop('rpm_worker_default') || Resque.pop('rpm_worker')) - redis = Resque.redis - kind_id = redis.spop(USER_BUILDS_SET) - key = "user_build_#{kind_id}_rpm_worker_default" if kind_id - task = Resque.pop(key) if key - redis.sadd(USER_BUILDS_SET, kind_id) if task + redis = Resque.redis + kind_id = redis.spop(USER_BUILDS_SET) + key = "user_build_#{kind_id}_rpm_worker_default" if kind_id + task = Resque.pop(key) if key + redis.sadd(USER_BUILDS_SET, kind_id) if task - kind_id ||= redis.spop(MASS_BUILDS_SET) - key ||= "mass_build_#{kind_id}_rpm_worker" if kind_id - task ||= Resque.pop(key) if key - redis.sadd(MASS_BUILDS_SET, kind_id) if task && key =~ /^mass_build/ - end + kind_id ||= redis.spop(MASS_BUILDS_SET) + key ||= "mass_build_#{kind_id}_rpm_worker" if kind_id + task ||= Resque.pop(key) if key + redis.sadd(MASS_BUILDS_SET, kind_id) if task && key =~ /^mass_build/ if task build_list = BuildList.where(id: task['args'][0]['id']).first diff --git a/config/schedule.rb b/config/schedule.rb index 0d04267e2..9e9cb2b29 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -26,14 +26,6 @@ every :day, at: '3:00 am' do rake 'activity_feeds:clear', output: 'log/activity_feeds.log' end -every 3.minute do - runner 'AbfWorker::BuildListsPublishTaskManager.new.run', output: 'log/task_manager.log' -end - -every 1.minute do - runner 'RpmBuildNode.cleanup!' -end - every 1.hour do rake 'buildlist:clear:outdated_canceling', output: 'log/canceling_build_list_clear.log' end diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake index 13c8f72f5..76cafb58a 100644 --- a/lib/tasks/resque.rake +++ b/lib/tasks/resque.rake @@ -7,4 +7,17 @@ namespace :resque do end system("kill -QUIT #{pids.join(' ')}") if pids.size > 0 end + + # This fixes connection fail with Postgres server on new fork: + task setup: :environment do + Resque.after_fork do + Resque.redis.client.reconnect + end + Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } + end + + task scheduler_setup: :environment do + Resque.schedule = YAML.load_file(Rails.root.join('config', 'resque_schedule.yml')) + end + end