Fixed: cleaning of old queues
This commit is contained in:
parent
4bde41588a
commit
5b15444543
|
@ -17,7 +17,7 @@ class BuildListsQueuesMonitoringJob
|
||||||
end
|
end
|
||||||
last_updated_at = last_updated_at.try(:updated_at)
|
last_updated_at = last_updated_at.try(:updated_at)
|
||||||
# cleans queue if no activity and tasks for this queue
|
# cleans queue if no activity and tasks for this queue
|
||||||
clean(key, !last_updated_at || (last_updated_at + 5.minutes) < Time.zone.now)
|
clean(key) if !last_updated_at || (last_updated_at + 5.minutes) < Time.zone.now
|
||||||
else
|
else
|
||||||
# ensures that user/mass-build in the set from which we select next jobs
|
# ensures that user/mass-build in the set from which we select next jobs
|
||||||
set_key = key =~ /^user/ ? BuildList::USER_BUILDS_SET : BuildList::MASS_BUILDS_SET
|
set_key = key =~ /^user/ ? BuildList::USER_BUILDS_SET : BuildList::MASS_BUILDS_SET
|
||||||
|
@ -27,13 +27,18 @@ class BuildListsQueuesMonitoringJob
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.clean(key, and_condition)
|
def self.clean(key)
|
||||||
queue = "queue:#{key}"
|
queue = "queue:#{key}"
|
||||||
redis.multi do
|
redis.watch(queue) do
|
||||||
redis.watch queue
|
if redis.llen(queue) == 0
|
||||||
redis.del queue
|
redis.multi do |multi|
|
||||||
redis.srem 'queues', key
|
multi.del queue
|
||||||
end if redis.llen(queue) == 0 && and_condition
|
multi.srem 'queues', key
|
||||||
|
end
|
||||||
|
else
|
||||||
|
redis.unwatch
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.redis
|
def self.redis
|
||||||
|
|
|
@ -12,7 +12,7 @@ build_lists_publish_task_manager:
|
||||||
queue: hook
|
queue: hook
|
||||||
description: 'Creates tasks for publishing'
|
description: 'Creates tasks for publishing'
|
||||||
|
|
||||||
clean_build_lists_queues:
|
build_lists_queues_monitoring:
|
||||||
every:
|
every:
|
||||||
- '1m'
|
- '1m'
|
||||||
class: 'BuildListsQueuesMonitoringJob'
|
class: 'BuildListsQueuesMonitoringJob'
|
||||||
|
|
Loading…
Reference in New Issue