Permalink
Browse files

Clean/restore queues

  • Loading branch information...
1 parent 5f5ed0d commit f1323bf9bd42b2f4b82469734de6298d495d38bc @avokhmin avokhmin committed Feb 21, 2014
Showing with 10 additions and 9 deletions.
  1. +9 −9 app/models/build_list.rb
  2. +1 −0 lib/abf_worker/model_helper.rb
@@ -543,22 +543,22 @@ def cleanup_packages_from_testing
def self.next_build
unless task = (Resque.pop('rpm_worker_default') || Resque.pop('rpm_worker'))
- kind_id = Resque.redis.spop(USER_BUILDS_SET)
+ 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
- Resque.redis.sadd(USER_BUILDS_SET, kind_id) if task
+ redis.sadd(USER_BUILDS_SET, kind_id) if task
- kind_id ||= Resque.redis.spop(MASS_BUILDS_SET)
+ kind_id ||= redis.spop(MASS_BUILDS_SET)
key ||= "mass_build_#{kind_id}_rpm_worker" if kind_id
task ||= Resque.pop(key) if key
- Resque.redis.sadd(MASS_BUILDS_SET, kind_id) if task && key =~ /^mass_build/
+ redis.sadd(MASS_BUILDS_SET, kind_id) if task && key =~ /^mass_build/
- Resque.redis.multi do
- if Resque.redis.llen("queue:#{key}") == 0
- Resque.redis.del "queue:#{key}"
- end
- end if task
+ if task && redis.llen("queue:#{key}") == 0
+ redis.del "queue:#{key}"
+ redis.srem 'queues', key
+ end
end
if task
@@ -39,6 +39,7 @@ def add_job_to_abf_worker_queue
def restart_job
update_build_sets
+ Resque.redis.sadd 'queues', worker_queue_with_priority
Resque.redis.lpush "queue:#{worker_queue_with_priority}",
Resque.encode({'class' => worker_queue_class, 'args' => [abf_worker_args]})
end

0 comments on commit f1323bf

Please sign in to comment.