diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index d52acf71c..0da551cb9 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -31,11 +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 = begin - BuildServer.get_status - rescue Exception # Timeout::Error - {} - end + @build_server_status = AbfWorker::StatusInspector.get_status end def new diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 1ff978ed0..93446409f 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -45,7 +45,7 @@ class BuildList < ActiveRecord::Base attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash, :arch_id, :project_id, :save_to_repository_id, :update_type, - :save_to_platform_id, :new_core, :project_version + :save_to_platform_id, :project_version LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 338f2db1f..77b52a940 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -17,9 +17,6 @@ .both.bottom_20 = check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish' = label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish') - %br - = check_box_tag :new_core, true, false - = label_tag :new_core, t('activerecord.attributes.build_list.new_core') %br %br diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 939d76789..6656511e0 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -2,19 +2,16 @@ .bordered.nopadding %h3= t('layout.build_lists.build_server_status.header') - .table - .lefter= t('layout.build_lists.build_server_status.client_count') - .righter= @build_server_status['client_count'] - .both - .table - .lefter= t('layout.build_lists.build_server_status.count_new_task') - .righter= @build_server_status['count_new_task'] - .both - .table - .lefter= t('layout.build_lists.build_server_status.count_build_task') - .righter= @build_server_status['count_build_task'] - .both - %br + - [: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) = form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f| diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 4bbe74950..55f8aabc2 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -26,9 +26,6 @@ .both = f.check_box :auto_publish = f.label :auto_publish - .both - = f.check_box :new_core - = f.label :new_core %br = f.submit t("layout.projects.build_button") diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 8ee6de255..43128a667 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -88,9 +88,11 @@ en: build_server_status: header: Build server status - client_count: Number of clients - count_new_task: Number of tasks in queue - count_build_task: Number of tasks in execution + count: '- count' + tasks: '- tasks in queue' + build_tasks: '- tasks in execution' + rpm_workers: Workers for building + publish_workers: Workers for publishing items: statuses: diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 95c9107de..3b9489aaa 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -85,9 +85,11 @@ ru: build_server_status: header: Статус сборочного сервера - client_count: Число клиентов - count_new_task: Число заданий в очереди - count_build_task: Число выполняемых заданий + count: '- число' + tasks: '- заданий в очереди' + build_tasks: '- заданий выполняется' + rpm_workers: Воркеров для сборки + publish_workers: Воркеров для публикации items: statuses: diff --git a/lib/abf_worker/status_inspector.rb b/lib/abf_worker/status_inspector.rb new file mode 100644 index 000000000..cf0f50921 --- /dev/null +++ b/lib/abf_worker/status_inspector.rb @@ -0,0 +1,20 @@ +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" + 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 \ No newline at end of file diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index dfe5f8b86..b6c6bb128 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -280,22 +280,6 @@ describe Projects::BuildListsController do end - context 'for admin' do - before(:each) { set_session_for FactoryGirl.create(:admin) } - - it "should be able to perform index action without exception" do - any_instance_of(XMLRPC::Client) do |xml_rpc| - stub(xml_rpc).call do |args| - raise Timeout::Error - end - end - get :index - assigns[:build_server_status].should == {} - response.should be_success - end - end - end - context 'filter' do before(:each) do