Use resque-schedule for cleanup
This commit is contained in:
parent
8d178b856f
commit
fe20a9788a
|
@ -0,0 +1,8 @@
|
||||||
|
class BuildListsPublishTaskManagerJob
|
||||||
|
@queue = :hook
|
||||||
|
|
||||||
|
def self.perform
|
||||||
|
AbfWorker::BuildListsPublishTaskManager.new.run
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,18 @@
|
||||||
|
class CleanBuildListsQueuesJob
|
||||||
|
@queue = :hook
|
||||||
|
|
||||||
|
def self.perform
|
||||||
|
redis = Resque.redis
|
||||||
|
redis.smembers('queues').each do |key|
|
||||||
|
next if key !~ /(user|mass)_build_/
|
||||||
|
queue = "queue:#{key}"
|
||||||
|
if redis.llen(queue) == 0
|
||||||
|
redis.multi do
|
||||||
|
redis.del queue
|
||||||
|
redis.srem 'queues', key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CleanRpmBuildNodeJob
|
||||||
|
@queue = :hook
|
||||||
|
|
||||||
|
def self.perform
|
||||||
|
RpmBuildNode.all.each do |n|
|
||||||
|
n.delete unless n.user_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -558,7 +558,6 @@ class BuildList < ActiveRecord::Base
|
||||||
|
|
||||||
if task
|
if task
|
||||||
build_list = BuildList.where(id: task['args'][0]['id']).first
|
build_list = BuildList.where(id: task['args'][0]['id']).first
|
||||||
build_list.cleanup_build_sets
|
|
||||||
build_list.delayed_add_job_to_abf_worker_queue
|
build_list.delayed_add_job_to_abf_worker_queue
|
||||||
build_list
|
build_list
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,6 @@ class RpmBuildNode < Ohm::Model
|
||||||
User.where(id: user_id).first
|
User.where(id: user_id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cleanup!
|
|
||||||
RpmBuildNode.all.each do |n|
|
|
||||||
n.delete unless n.user_id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.total_statistics
|
def self.total_statistics
|
||||||
systems, others, busy = 0, 0, 0
|
systems, others, busy = 0, 0, 0
|
||||||
RpmBuildNode.all.select{ |n| n.user_id }.each do |n|
|
RpmBuildNode.all.select{ |n| n.user_id }.each do |n|
|
||||||
|
|
|
@ -27,6 +27,7 @@ module Rosa
|
||||||
# Custom directories with classes and modules you want to be autoloadable.
|
# Custom directories with classes and modules you want to be autoloadable.
|
||||||
# config.autoload_paths += %W(#{config.root}/extras)
|
# config.autoload_paths += %W(#{config.root}/extras)
|
||||||
config.autoload_paths += %W(#{config.root}/app/presenters)
|
config.autoload_paths += %W(#{config.root}/app/presenters)
|
||||||
|
config.autoload_paths += %W(#{config.root}/app/jobs)
|
||||||
|
|
||||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||||
|
|
|
@ -10,6 +10,7 @@ Resque::Mailer.excluded_environments = [:test]
|
||||||
|
|
||||||
unless Rails.env.test?
|
unless Rails.env.test?
|
||||||
PerformLater.config.enabled = true # this will default to false if unset
|
PerformLater.config.enabled = true # this will default to false if unset
|
||||||
|
Resque.schedule = YAML.load_file(File.join(Rails.root, 'config/resque_schedule.yml')) # load the schedule
|
||||||
end
|
end
|
||||||
|
|
||||||
Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds
|
Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
clean_rpm_build_nodes:
|
||||||
|
every:
|
||||||
|
- '1m'
|
||||||
|
class: 'CleanRpmBuildNodeJob'
|
||||||
|
queue: hook
|
||||||
|
description: 'Cleans RPM build nodes'
|
||||||
|
|
||||||
|
build_lists_publish_task_manager:
|
||||||
|
every:
|
||||||
|
- '3m'
|
||||||
|
class: 'BuildListsPublishTaskManagerJob'
|
||||||
|
queue: hook
|
||||||
|
description: 'Creates tasks for publishing'
|
||||||
|
|
||||||
|
clean_build_lists_queues:
|
||||||
|
every:
|
||||||
|
- '1m'
|
||||||
|
class: 'CleanBuildListsQueuesJob'
|
||||||
|
queue: hook
|
||||||
|
description: 'Cleans build_lists queues'
|
|
@ -26,14 +26,6 @@ every :day, at: '3:00 am' do
|
||||||
rake 'activity_feeds:clear', output: 'log/activity_feeds.log'
|
rake 'activity_feeds:clear', output: 'log/activity_feeds.log'
|
||||||
end
|
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
|
every 1.hour do
|
||||||
rake 'buildlist:clear:outdated_canceling', output: 'log/canceling_build_list_clear.log'
|
rake 'buildlist:clear:outdated_canceling', output: 'log/canceling_build_list_clear.log'
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,7 +58,6 @@ module AbfWorker::ModelHelper
|
||||||
worker_queue_class,
|
worker_queue_class,
|
||||||
abf_worker_args
|
abf_worker_args
|
||||||
)
|
)
|
||||||
cleanup_build_sets
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,17 +81,6 @@ module AbfWorker::ModelHelper
|
||||||
"AbfWorker::#{abf_worker_base_queue.classify}#{abf_worker_priority.capitalize}"
|
"AbfWorker::#{abf_worker_base_queue.classify}#{abf_worker_priority.capitalize}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_build_sets
|
|
||||||
return unless is_a?(BuildList)
|
|
||||||
queue = worker_queue_with_priority
|
|
||||||
if Resque.redis.llen("queue:#{queue}") == 0
|
|
||||||
key = mass_build_id ? MASS_BUILDS_SET : USER_BUILDS_SET
|
|
||||||
Resque.redis.srem key, mass_build_id || user_id
|
|
||||||
Resque.redis.del "queue:#{queue}"
|
|
||||||
Resque.redis.srem 'queues', queue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue