2013-01-21 15:52:20 +00:00
|
|
|
module AbfWorker
|
|
|
|
class StatusInspector
|
|
|
|
|
2013-01-24 10:42:03 +00:00
|
|
|
class << self
|
|
|
|
def projects_status
|
|
|
|
get_status(:rpm, :publish) { |w, worker|
|
|
|
|
w.to_s =~ /#{worker}_worker_default/
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def products_status
|
|
|
|
get_status(:iso) { |w, worker|
|
|
|
|
str = w.to_s
|
|
|
|
str =~ /iso_worker/ && str !~ /observer/
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def get_status(*queues)
|
|
|
|
status = {}
|
|
|
|
queues.each do |worker|
|
|
|
|
workers = Resque.workers.select{ |w| yield w, worker }
|
2013-01-24 11:58:42 +00:00
|
|
|
status[worker] = status_of_worker workers, worker
|
2013-01-24 10:42:03 +00:00
|
|
|
end
|
|
|
|
status
|
|
|
|
end
|
|
|
|
|
2013-01-24 11:58:42 +00:00
|
|
|
def status_of_worker(workers, worker)
|
2013-01-24 10:42:03 +00:00
|
|
|
redis, key = Resque.redis, "queue:#{worker}_worker"
|
2013-05-24 09:35:10 +01:00
|
|
|
default_tasks, tasks = redis.llen("#{key}_default"), redis.llen(key)
|
2013-01-24 11:58:42 +00:00
|
|
|
{
|
2013-05-24 09:47:35 +01:00
|
|
|
:workers => workers.count,
|
2013-05-24 09:35:10 +01:00
|
|
|
:build_tasks => workers.select{ |w| w.working? }.count,
|
2013-05-24 10:26:32 +01:00
|
|
|
:default_tasks => default_tasks,
|
|
|
|
:low_tasks => tasks,
|
|
|
|
:tasks => (default_tasks + tasks)
|
2013-01-21 15:52:20 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-01-24 10:42:03 +00:00
|
|
|
end
|
2013-01-21 15:52:20 +00:00
|
|
|
end
|
|
|
|
end
|