#848: update StatusInspector, UI
This commit is contained in:
parent
e65a00e622
commit
b46c1e963f
|
@ -80,6 +80,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
|||
@product_build_lists = @product_build_lists.for_status(params[:status]) if params[:status].present?
|
||||
end
|
||||
@product_build_lists = @product_build_lists.recent.paginate :page => params[:page]
|
||||
@build_server_status = AbfWorker::StatusInspector.products_status
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -31,7 +31,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
@build_lists = BuildList.where(:id => @bls.pluck("#{BuildList.table_name}.id")).recent
|
||||
@build_lists = @build_lists.includes [:save_to_platform, :save_to_repository, :arch, :user, :project => [:owner]]
|
||||
|
||||
@build_server_status = AbfWorker::StatusInspector.get_status
|
||||
@build_server_status = AbfWorker::StatusInspector.projects_status
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
- content_for :sidebar do
|
||||
= render 'projects/build_lists/server_status', :queues => [:iso]
|
||||
|
||||
= form_tag product_build_lists_path, :method => :get, :html => {:class => :form} do
|
||||
.block
|
||||
%h3.small= t("activerecord.attributes.product_build_list.status")
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
- content_for :sidebar do
|
||||
.bordered.nopadding
|
||||
%h3= t('layout.build_lists.build_server_status.header')
|
||||
|
||||
- [:rpm, :publish].each do |queue|
|
||||
.table
|
||||
.lefter= t("layout.build_lists.build_server_status.#{queue}_workers")
|
||||
.both
|
||||
- [:count, :tasks, :build_tasks].each do |metric|
|
||||
.table
|
||||
.lefter= t("layout.build_lists.build_server_status.#{metric}")
|
||||
.righter= @build_server_status[queue][metric]
|
||||
.both
|
||||
%br
|
||||
= link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project.build_lists.build)
|
||||
= render 'server_status'
|
||||
|
||||
= form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
|
||||
- if current_user
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
- queues ||= [:rpm, :publish]
|
||||
.bordered.nopadding
|
||||
%h3= t('layout.build_lists.build_server_status.header')
|
||||
|
||||
- queues.each do |queue|
|
||||
.table
|
||||
.lefter= t("layout.build_lists.build_server_status.#{queue}_workers")
|
||||
.both
|
||||
- [:count, :tasks, :build_tasks].each do |metric|
|
||||
.table
|
||||
.lefter= t("layout.build_lists.build_server_status.#{metric}")
|
||||
.righter= @build_server_status[queue][metric]
|
||||
.both
|
||||
%br
|
||||
= link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project.build_lists.build)
|
|
@ -93,6 +93,7 @@ en:
|
|||
tasks: '- tasks in queue'
|
||||
build_tasks: '- tasks in execution'
|
||||
rpm_workers: Workers for building
|
||||
iso_workers: Workers for building
|
||||
publish_workers: Workers for publishing
|
||||
|
||||
items:
|
||||
|
|
|
@ -90,6 +90,7 @@ ru:
|
|||
tasks: '- заданий в очереди'
|
||||
build_tasks: '- заданий выполняется'
|
||||
rpm_workers: Воркеров для сборки
|
||||
iso_workers: Воркеров для сборки
|
||||
publish_workers: Воркеров для публикации
|
||||
|
||||
items:
|
||||
|
|
|
@ -1,20 +1,40 @@
|
|||
module AbfWorker
|
||||
class StatusInspector
|
||||
|
||||
def self.get_status
|
||||
redis, all_workers = Resque.redis, Resque.workers
|
||||
status = {}
|
||||
[:rpm, :publish].each do |worker|
|
||||
workers = all_workers.select{ |w| w.to_s =~ /#{worker}_worker_default/ }
|
||||
key = "queue:#{worker}_worker"
|
||||
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 }
|
||||
fill_status status, workers, worker
|
||||
end
|
||||
status
|
||||
end
|
||||
|
||||
def fill_status(status, workers, worker)
|
||||
redis, key = Resque.redis, "queue:#{worker}_worker"
|
||||
status[worker] = {
|
||||
:count => workers.count,
|
||||
:build_tasks => workers.select{ |w| w.working? }.count,
|
||||
:tasks => (redis.llen("#{key}_default") + redis.llen(key))
|
||||
}
|
||||
end
|
||||
status
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue