diff --git a/Capfile b/Capfile deleted file mode 100644 index ae1f8735e..000000000 --- a/Capfile +++ /dev/null @@ -1,8 +0,0 @@ -load 'deploy' if respond_to?(:namespace) # cap2 differentiator - -# Uncomment if you are using Rails' asset pipeline -load 'deploy/assets' - -Dir['vendor/gems/*/recipes/*.rb', 'vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } - -load 'config/deploy' # remove this line to skip loading any of the default tasks diff --git a/Gemfile b/Gemfile index 7e019362c..59d4b7630 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,15 @@ gem 'devise' gem 'pundit' gem 'paperclip' -gem 'resque' -gem 'resque-status' -gem 'resque_mailer' -gem 'resque-scheduler', '~>2.5.4' -gem 'perform_later', git: 'git://github.com/KensoDev/perform_later.git' # should be after resque_mailer +gem 'sinatra', :require => nil +gem 'sidekiq' +gem 'kiqit' +gem 'sidekiq-scheduler', '~> 2.0' +#gem 'resque' +#gem 'resque-status' +#gem 'resque_mailer' +#gem 'resque-scheduler', '~>2.5.4' +#gem 'perform_later', git: 'git://github.com/KensoDev/perform_later.git' # should be after resque_mailer gem 'russian' gem 'state_machines-activerecord' gem 'redis-rails' @@ -79,6 +83,7 @@ group :development do gem 'rails3-generators' gem 'hirb' gem 'shotgun' + gem 'state_machines-graphviz' # Better Errors & RailsPanel gem 'better_errors' gem 'binding_of_caller' diff --git a/Gemfile.lock b/Gemfile.lock index 3e31f1695..ab0323577 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,3 @@ -GIT - remote: git://github.com/KensoDev/perform_later.git - revision: afd40794aa7101c8e73e9f105a064dd9bec47e31 - specs: - perform_later (1.3.0) - rails (>= 3.0) - redis - resque (> 1.25) - resque-scheduler - GIT remote: git://github.com/activeadmin/activeadmin.git revision: cce908d9793ba1fce8483afe5e4112f97d7d0857 @@ -122,6 +112,7 @@ GEM sass-rails (< 5.1) sprockets (< 4.0) concurrent-ruby (1.0.2) + connection_pool (2.2.0) crack (0.4.3) safe_yaml (~> 1.0.0) daemons (1.2.3) @@ -202,6 +193,9 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) key_struct (0.4.2) + kiqit (2.4.0) + activerecord + sidekiq (> 2.5) libv8 (3.16.14.15) localeapp (1.0.2) gli @@ -237,7 +231,6 @@ GEM modware (0.1.2) its-it key_struct (~> 0.4) - mono_logger (1.1.0) multi_json (1.12.1) multipart-post (2.0.0) nest (1.1.2) @@ -326,7 +319,7 @@ GEM rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) - redis (3.0.7) + redis (3.3.0) redis-actionpack (4.0.1) actionpack (~> 4) redis-rack (~> 1.5.0) @@ -334,8 +327,6 @@ GEM redis-activesupport (4.1.5) activesupport (>= 3, < 5) redis-store (~> 1.1.0) - redis-namespace (1.5.2) - redis (~> 3.0, >= 3.0.4) redis-rack (1.5.0) rack (~> 1.5) redis-store (~> 1.1.0) @@ -350,21 +341,6 @@ GEM ref (2.0.0) responders (2.2.0) railties (>= 4.2.0, < 5.1) - resque (1.25.2) - mono_logger (~> 1.0) - multi_json (~> 1.0) - redis-namespace (~> 1.3) - sinatra (>= 0.9.2) - vegas (~> 0.1.2) - resque-scheduler (2.5.5) - mono_logger (~> 1.0) - redis (~> 3.0.4) - resque (~> 1.25.1) - rufus-scheduler (~> 2.0.24) - resque-status (0.5.0) - resque (~> 1.19) - resque_mailer (2.3.0) - actionmailer (>= 3.0) rest-client (1.8.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) @@ -387,13 +363,13 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) + ruby-graphviz (1.2.2) ruby-haml-js (0.0.5) execjs sprockets (>= 2.0.0) ruby_parser (3.8.2) sexp_processor (~> 4.1) - rufus-scheduler (2.0.24) - tzinfo (>= 0.3.22) + rufus-scheduler (3.1.10) russian (0.6.0) i18n (>= 0.5.0) safe_yaml (1.0.4) @@ -470,6 +446,16 @@ GEM shoulda-context (1.2.1) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) + sidekiq (4.1.2) + concurrent-ruby (~> 1.0) + connection_pool (~> 2.2, >= 2.2.0) + redis (~> 3.2, >= 3.2.1) + sidekiq-scheduler (2.0.7) + multi_json (~> 1) + redis (~> 3) + rufus-scheduler (~> 3.1.8) + sidekiq (>= 3) + tilt (>= 1.4.0) simple_form (3.1.0.rc2) actionpack (~> 4.0) activemodel (~> 4.0) @@ -477,8 +463,6 @@ GEM rack (~> 1.5) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - sitemap_generator (5.1.0) - builder skinny (0.2.4) eventmachine (~> 1.0.0) thin (>= 1.5, < 1.7) @@ -501,6 +485,9 @@ GEM state_machines-activerecord (0.4.0) activerecord (>= 4.1, < 5.1) state_machines-activemodel (>= 0.3.0) + state_machines-graphviz (0.0.2) + ruby-graphviz + state_machines temple (0.7.7) test_after_commit (1.0.0) activerecord (>= 3.2) @@ -526,8 +513,6 @@ GEM unf_ext unf_ext (0.0.7.2) valuable (0.9.12) - vegas (0.1.11) - rack (>= 1.0.0) warden (1.2.6) rack (>= 1.0) webmock (2.0.3) @@ -559,6 +544,7 @@ DEPENDENCIES hirb jbuilder js-routes + kiqit localeapp mailcatcher meta-tags @@ -571,7 +557,6 @@ DEPENDENCIES ohm (~> 1.3.2) ohm-expire (~> 0.1.3) paperclip - perform_later! pg puma pundit @@ -585,10 +570,6 @@ DEPENDENCIES rake redis-rails redis-semaphore - resque - resque-scheduler (~> 2.5.4) - resque-status - resque_mailer rest-client rr rspec-rails @@ -599,12 +580,15 @@ DEPENDENCIES shotgun shoulda shoulda-matchers + sidekiq + sidekiq-scheduler (~> 2.0) simple_form (= 3.1.0.rc2) - sitemap_generator + sinatra slim soundmanager-rails sprockets state_machines-activerecord + state_machines-graphviz test_after_commit therubyracer therubyrhino diff --git a/Rakefile b/Rakefile index 562c9b3d7..035ccba70 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,5 @@ require File.expand_path('../config/application', __FILE__) require 'rake' -require 'resque/tasks' -require 'resque_scheduler/tasks' Rosa::Application.load_tasks diff --git a/app/admin/resque.rb b/app/admin/resque.rb deleted file mode 100644 index 2dfdc7105..000000000 --- a/app/admin/resque.rb +++ /dev/null @@ -1,3 +0,0 @@ -ActiveAdmin.register_page 'Resque' do - menu priority: 100, label: 'Resque', url: '/admin/resque/overview' -end \ No newline at end of file diff --git a/app/assets/javascripts/angularjs/angular-templates.js b/app/assets/javascripts/angularjs/angular-templates.js deleted file mode 100644 index 03202fce1..000000000 --- a/app/assets/javascripts/angularjs/angular-templates.js +++ /dev/null @@ -1,190 +0,0 @@ -angular.module("u2i.bootstrap.tpls", ["uib/template/tabs/tab.html", "uib/template/tabs/tabset.html", "uib/template/typeahead/typeahead-match.html", - "uib/template/typeahead/typeahead-popup.html", "uib/template/pagination/pager.html", - "uib/template/pagination/pagination.html", "uib/template/datepicker/datepicker.html", - "uib/template/datepicker/popup.html", "uib/template/datepicker/year.html", - "uib/template/datepicker/month.html", "uib/template/datepicker/day.html"]); - -angular.module("uib/template/tabs/tab.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/tabs/tab.html", - "
  • \n" + - " {{heading}}\n" + - "
  • \n" + - ""); -}]); - -angular.module("uib/template/tabs/tabset.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/tabs/tabset.html", - "
    \n" + - " \n" + - "
    \n" + - "
    \n" + - "
    \n" + - "
    \n" + - "
    \n" + - ""); -}]); - -angular.module("uib/template/typeahead/typeahead-match.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/typeahead/typeahead-match.html", - "\n" + - ""); -}]); - -angular.module("uib/template/typeahead/typeahead-popup.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/typeahead/typeahead-popup.html", - "\n" + - ""); -}]); - -angular.module("uib/template/pagination/pager.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/pagination/pager.html", - "\n" + - ""); -}]); - -angular.module("uib/template/pagination/pagination.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/pagination/pagination.html", - "\n" + - ""); -}]); - -angular.module("uib/template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/datepicker/datepicker.html", - "
    \n" + - " \n" + - " \n" + - " \n" + - "
    \n" + - ""); -}]); - -angular.module("uib/template/datepicker/day.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/datepicker/day.html", - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
    {{::label.abbr}}
    {{ weekNumbers[$index] }}\n" + - " \n" + - "
    \n" + - ""); -}]); - -angular.module("uib/template/datepicker/month.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/datepicker/month.html", - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
    \n" + - " \n" + - "
    \n" + - ""); -}]); - -angular.module("uib/template/datepicker/popup.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/datepicker/popup.html", - "
    \n" + - " \n" + - "
    \n" + - ""); -}]); - -angular.module("uib/template/datepicker/year.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("uib/template/datepicker/year.html", - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
    \n" + - " \n" + - "
    \n" + - ""); -}]); \ No newline at end of file diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index d84b52f1d..282d9b08a 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -91,7 +91,7 @@ class Api::V1::JobsController < Api::V1::BaseController if QUEUES.include?(worker_queue) && QUEUE_CLASSES.include?(worker_class) worker_args = (params[:worker_args] || []).first || {} worker_args = worker_args.merge(feedback_from_user: current_user.id) - Resque.push worker_queue, 'class' => worker_class, 'args' => [worker_args] + Sidekiq::Client.push 'queue' => worker_queue, 'class' => worker_class, 'args' => [worker_args] render nothing: true else render nothing: true, status: 403 diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index 78e32bb8a..277a035d1 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -88,7 +88,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController @product_build_lists = @product_build_lists. includes(:project, product: :platform). recent.paginate(page: current_page) - @build_server_status = AbfWorkerStatusPresenter.new.products_status + #@build_server_status = AbfWorkerStatusPresenter.new.products_status end protected diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 4197e04d9..12be9f7bd 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -35,7 +35,7 @@ class Projects::BuildListsController < Projects::BaseController :source_packages, project: :project_statistics) - @build_server_status = AbfWorkerStatusPresenter.new.projects_status + #@build_server_status = AbfWorkerStatusPresenter.new.projects_status end end end @@ -103,21 +103,21 @@ class Projects::BuildListsController < Projects::BaseController if prs.present? && prs[:projects].present? && prs[:arches].present? project_ids = prs[:projects].select{ |k, v| v == '1' }.keys arch_ids = prs[:arches]. select{ |k, v| v == '1' }.keys - - Resque.enqueue( - BuildLists::DependentPackagesJob, - @build_list.id, - current_user.id, - project_ids, - arch_ids, - { - auto_publish_status: prs[:auto_publish_status], - auto_create_container: prs[:auto_create_container], - include_testing_subrepository: prs[:include_testing_subrepository], - use_cached_chroot: prs[:use_cached_chroot], - use_extra_tests: prs[:use_extra_tests] - } - ) + #FIX +# enqueue( +# BuildLists::DependentPackagesJob, +# @build_list.id, +# current_user.id, +# project_ids, +# arch_ids, +# { +# auto_publish_status: prs[:auto_publish_status], +# auto_create_container: prs[:auto_create_container], +# include_testing_subrepository: prs[:include_testing_subrepository], +# use_cached_chroot: prs[:use_cached_chroot], +# use_extra_tests: prs[:use_extra_tests] +# } +# ) flash[:notice] = t('flash.build_list.dependent_projects_job_added_to_queue') redirect_to build_list_path(@build_list) end diff --git a/app/jobs/abf_worker/base_observer.rb b/app/jobs/abf_worker/base_observer.rb index 79af23b49..8bc2c91b1 100644 --- a/app/jobs/abf_worker/base_observer.rb +++ b/app/jobs/abf_worker/base_observer.rb @@ -1,5 +1,7 @@ module AbfWorker - class BaseObserver + class BaseObserver < BaseActiveRecordJob + include Sidekiq::Worker + COMPLETED = 0 FAILED = 1 PENDING = 2 @@ -9,13 +11,13 @@ module AbfWorker attr_accessor :status, :options - def initialize(options, subject_class) + def perform(options) @status = options['status'].to_i @options = options - @subject_class = subject_class + real_perform end - def perform + def real_perform raise NotImplementedError, "You should implement this method" end diff --git a/app/jobs/abf_worker/iso_worker_observer.rb b/app/jobs/abf_worker/iso_worker_observer.rb index d6e6fd086..3e6fc866f 100644 --- a/app/jobs/abf_worker/iso_worker_observer.rb +++ b/app/jobs/abf_worker/iso_worker_observer.rb @@ -1,30 +1,29 @@ module AbfWorker class IsoWorkerObserver < AbfWorker::BaseObserver - @queue = :iso_worker_observer + sidekiq_options :queue => :iso_worker_observer - def self.perform(options) - new(options, ProductBuildList).perform - end + def real_perform + @subject_class = ProductBuildList + subject.with_lock do + case status + when COMPLETED + subject.build_success + when FAILED - def perform - case status - when COMPLETED - subject.build_success - when FAILED + case options['exit_status'].to_i + when ProductBuildList::BUILD_COMPLETED_PARTIALLY + subject.build_success_partially + else + subject.build_error + end - case options['exit_status'].to_i - when ProductBuildList::BUILD_COMPLETED_PARTIALLY - subject.build_success_partially - else - subject.build_error + when STARTED + subject.start_build + when CANCELED + subject.build_canceled end - - when STARTED - subject.start_build - when CANCELED - subject.build_canceled + update_results if status != STARTED end - update_results if status != STARTED end end diff --git a/app/jobs/abf_worker/publish_observer.rb b/app/jobs/abf_worker/publish_observer.rb index 9600ac904..faa41ba83 100644 --- a/app/jobs/abf_worker/publish_observer.rb +++ b/app/jobs/abf_worker/publish_observer.rb @@ -1,12 +1,9 @@ module AbfWorker class PublishObserver < AbfWorker::BaseObserver - @queue = :publish_observer + sidekiq_options :queue => :publish_observer - def self.perform(options) - new(options, BuildList).perform - end - - def perform + def real_perform + @subject_class = BuildList return if status == STARTED # do nothing when publication started extra = options['extra'] repository_status = RepositoryStatus.where(id: extra['repository_status_id']).first diff --git a/app/jobs/abf_worker/rpm_worker_observer.rb b/app/jobs/abf_worker/rpm_worker_observer.rb index 2f9fcd8dc..474d6c21c 100644 --- a/app/jobs/abf_worker/rpm_worker_observer.rb +++ b/app/jobs/abf_worker/rpm_worker_observer.rb @@ -7,88 +7,73 @@ module AbfWorker # other - Build error EXIT_CODE_UNPERMITTED_ARCHITECTURE = 6 - @queue = :rpm_worker_observer + sidekiq_options :queue => :rpm_worker_observer - def self.perform(options) - new(options, BuildList).perform - end + def real_perform + @subject_class = BuildList + subject.with_lock do + unless subject.valid? && restart_task + if options['feedback_from_user'] + user = User.find options['feedback_from_user'] + raise ActiveRecord::Rollback if !user.system? && subject.builder != user + end - def perform - return if subject.valid? && restart_task - if options['feedback_from_user'] - user = User.find options['feedback_from_user'] - return if !user.system? && subject.builder != user - end + fill_container_data if status != STARTED - item = find_or_create_item - fill_container_data if status != STARTED + unless subject.valid? + subject.build_error(false) + subject.save(validate: false) + return + end - unless subject.valid? - item.update_attributes({status: BuildList::BUILD_ERROR}) - subject.build_error(false) - subject.save(validate: false) - return - end + if options['hostname'] + subject.update_attribute(:hostname, options['hostname']) + end - if options['hostname'] - subject.update_attribute(:hostname, options['hostname']) - end + if options['fail_reason'] + subject.update_attribute(:fail_reason, options['fail_reason']) + end - if options['fail_reason'] - subject.update_attribute(:fail_reason, options['fail_reason']) - end + if options['commit_hash'] + subject.update_attribute(:commit_hash, options['commit_hash']) + end - if options['commit_hash'] - item.update_attribute(:version, options['commit_hash']) - subject.update_attribute(:commit_hash, options['commit_hash']) - end + rerunning_tests = subject.rerunning_tests? - rerunning_tests = subject.rerunning_tests? + case status + when COMPLETED + subject.build_success + if subject.can_auto_publish? && subject.can_publish? + subject.now_publish + elsif subject.auto_publish_into_testing? && subject.can_publish_into_testing? + subject.publish_into_testing + end + when FAILED - case status - when COMPLETED - subject.build_success - if subject.can_auto_publish? && subject.can_publish? - subject.now_publish - elsif subject.auto_publish_into_testing? && subject.can_publish_into_testing? - subject.publish_into_testing + case options['exit_status'].to_i + when EXIT_CODE_UNPERMITTED_ARCHITECTURE + subject.unpermitted_arch + else + subject.build_error + end + + when STARTED + subject.start_build + when CANCELED + subject.build_canceled + when TESTS_FAILED + subject.tests_failed + end + + if !rerunning_tests && [TESTS_FAILED, COMPLETED].include?(status) + subject.publish_container if subject.auto_create_container? + end end - when FAILED - - case options['exit_status'].to_i - when EXIT_CODE_UNPERMITTED_ARCHITECTURE - subject.unpermitted_arch - else - subject.build_error - end - - item.update_attributes({status: BuildList::BUILD_ERROR}) unless rerunning_tests - when STARTED - subject.start_build - when CANCELED - item.update_attributes({status: BuildList::BUILD_CANCELED}) unless rerunning_tests || subject.tests_failed? - subject.build_canceled - when TESTS_FAILED - subject.tests_failed - end - - if !rerunning_tests && [TESTS_FAILED, COMPLETED].include?(status) - item.update_attributes({status: BuildList::SUCCESS}) - subject.publish_container if subject.auto_create_container? end end protected - def find_or_create_item - subject.items.first || subject.items.create({ - version: '', - name: subject.project.name, - status: BuildList::BUILD_STARTED, - level: 0 - }) - end - def restart_task return false if status != FAILED if Redis.current.lrem(RESTARTED_BUILD_LISTS, 0, subject.id) > 0 || (options['results'] || []).size > 1 diff --git a/app/jobs/autostart_builds_daily_job.rb b/app/jobs/autostart_builds_daily_job.rb index 43216a568..7b71b9d6f 100644 --- a/app/jobs/autostart_builds_daily_job.rb +++ b/app/jobs/autostart_builds_daily_job.rb @@ -1,7 +1,7 @@ -class AutostartBuildsDailyJob - @queue = :low +class AutostartBuildsDailyJob < BaseActiveRecordJob + include Sidekiq::Worker - def self.perform + def perform_with_ar_connection Product.autostart_iso_builds_once_a_day Project.autostart_build_lists_once_a_day end diff --git a/app/jobs/autostart_builds_once_every_twelve_hours_job.rb b/app/jobs/autostart_builds_once_every_twelve_hours_job.rb index 1f519ad66..6955a13d4 100644 --- a/app/jobs/autostart_builds_once_every_twelve_hours_job.rb +++ b/app/jobs/autostart_builds_once_every_twelve_hours_job.rb @@ -1,7 +1,7 @@ -class AutostartBuildsOnceEveryTwelveHoursJob - @queue = :low +class AutostartBuildsOnceEveryTwelveHoursJob < BaseActiveRecordJob + include Sidekiq::Worker - def self.perform + def perform_with_ar_connection Product.autostart_iso_builds_once_a_12_hours Project.autostart_build_lists_once_a_12_hours end diff --git a/app/jobs/autostart_builds_weekly_job.rb b/app/jobs/autostart_builds_weekly_job.rb index 405cf0f16..e5d0e472c 100644 --- a/app/jobs/autostart_builds_weekly_job.rb +++ b/app/jobs/autostart_builds_weekly_job.rb @@ -1,7 +1,7 @@ -class AutostartBuildsWeeklyJob - @queue = :low +class AutostartBuildsWeeklyJob < BaseActiveRecordJob + include Sidekiq::Worker - def self.perform + def perform_with_ar_connection Product.autostart_iso_builds_once_a_week Project.autostart_build_lists_once_a_week end diff --git a/app/jobs/base_active_record_job.rb b/app/jobs/base_active_record_job.rb new file mode 100644 index 000000000..4ec8d7a01 --- /dev/null +++ b/app/jobs/base_active_record_job.rb @@ -0,0 +1,10 @@ +class BaseActiveRecordJob + def perform(*args) + ActiveRecord::Base.connection_pool.with_connection do + perform_with_ar_connection(*args) + end + ensure + ActiveRecord::Base.clear_active_connections! + ActiveRecord::Base.connection.close + end +end \ No newline at end of file diff --git a/app/jobs/build_lists/build_canceling_destroy_job.rb b/app/jobs/build_lists/build_canceling_destroy_job.rb index f6ef363bd..d485df026 100644 --- a/app/jobs/build_lists/build_canceling_destroy_job.rb +++ b/app/jobs/build_lists/build_canceling_destroy_job.rb @@ -1,8 +1,9 @@ module BuildLists - class BuildCancelingDestroyJob - @queue = :low + class BuildCancelingDestroyJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def self.perform + def perform_with_ar_connection scope = BuildList.for_status(BuildList::BUILD_CANCELING).for_notified_date_period(nil, 1.hours.ago) scope.find_each(batch_size: 50) do |bl| diff --git a/app/jobs/build_lists/clean_buildroot_job.rb b/app/jobs/build_lists/clean_buildroot_job.rb index 90cdfae63..5c7b49589 100644 --- a/app/jobs/build_lists/clean_buildroot_job.rb +++ b/app/jobs/build_lists/clean_buildroot_job.rb @@ -1,10 +1,11 @@ module BuildLists - class CleanBuildrootJob - @queue = :middle + class CleanBuildrootJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :middle FILENAME = 'rpm-buildroot.tar.gz' - def self.perform + def perform_with_ar_connection build_lists = BuildList.where(save_buildroot: true). for_status(BuildList::BUILD_ERROR). where('updated_at < ?', Time.now - 1.hour). @@ -21,7 +22,9 @@ module BuildLists end end - def self.clean_file_store(buildroots) + private + + def clean_file_store(buildroots) buildroots.each do |r| FileStoreService::File.new(sha1: r['sha1']).destroy end diff --git a/app/jobs/build_lists/clear_builder_on_stale_build_lists_job.rb b/app/jobs/build_lists/clear_builder_on_stale_build_lists_job.rb index d10907881..30b1f6f33 100644 --- a/app/jobs/build_lists/clear_builder_on_stale_build_lists_job.rb +++ b/app/jobs/build_lists/clear_builder_on_stale_build_lists_job.rb @@ -1,11 +1,14 @@ module BuildLists - class ClearBuilderOnStaleBuildListsJob - @queue = :low + class ClearBuilderOnStaleBuildListsJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def self.perform - BuildList.where(["updated_at < ?", 120.seconds.ago]).where(status: BuildList::BUILD_PENDING).find_each(batch_size: 50) do |bl| - bl.builder = nil - bl.save + def perform_with_ar_connection + BuildList.transaction do + BuildList.where(["updated_at < ?", 120.seconds.ago]).where(status: BuildList::BUILD_PENDING).where.not(builder: nil).find_each(batch_size: 50) do |bl| + bl.builder = nil + bl.save + end end end end diff --git a/app/jobs/build_lists/create_container_job.rb b/app/jobs/build_lists/create_container_job.rb index 236fb81e9..23517998e 100644 --- a/app/jobs/build_lists/create_container_job.rb +++ b/app/jobs/build_lists/create_container_job.rb @@ -1,8 +1,9 @@ module BuildLists - class CreateContainerJob - @queue = :middle + class CreateContainerJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :middle - def self.perform(build_list_id) + def perform_with_ar_connection(build_list_id) build_list = BuildList.find(build_list_id) container = AbfWorkerService::Container.new(build_list) container.create! diff --git a/app/jobs/clean_api_defender_statistics_job.rb b/app/jobs/clean_api_defender_statistics_job.rb index 9f8a6d976..cacac0619 100644 --- a/app/jobs/clean_api_defender_statistics_job.rb +++ b/app/jobs/clean_api_defender_statistics_job.rb @@ -1,7 +1,7 @@ class CleanApiDefenderStatisticsJob - @queue = :low + include Sidekiq::Worker - def self.perform + def perform deadline = Date.today - 1.month Redis.current.keys.select do |key| next if key !~ /^throttle:/ diff --git a/app/jobs/clean_rpm_build_node_job.rb b/app/jobs/clean_rpm_build_node_job.rb index b31e4ec25..fb42fda80 100644 --- a/app/jobs/clean_rpm_build_node_job.rb +++ b/app/jobs/clean_rpm_build_node_job.rb @@ -1,7 +1,7 @@ class CleanRpmBuildNodeJob - @queue = :middle + include Sidekiq::Worker - def self.perform + def perform RpmBuildNode.all.each do |n| n.delete unless n.user_id end diff --git a/app/jobs/create_empty_metadata_job.rb b/app/jobs/create_empty_metadata_job.rb index c81577050..8884ca075 100644 --- a/app/jobs/create_empty_metadata_job.rb +++ b/app/jobs/create_empty_metadata_job.rb @@ -1,23 +1,21 @@ -class CreateEmptyMetadataJob < Struct.new(:class_name, :id) - @queue = :low +class CreateEmptyMetadataJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def perform + def perform_with_ar_connection(class_name, id) + @id = id case class_name when Platform.name create_empty_metadata_for_platform when Repository.name - create_empty_metadata_for_repository Repository.find(id) + create_empty_metadata_for_repository Repository.find(@id) end end - def self.perform(class_name, id) - new(class_name, id).perform - end - private def create_empty_metadata_for_platform - platform = Platform.main.opened.find id + platform = Platform.main.opened.find @id @platforms = [platform] repositories = Repository.joins(:platform). where(platforms: { platform_type: Platform::TYPE_PERSONAL }) diff --git a/app/jobs/destroy_project_from_repository_job.rb b/app/jobs/destroy_project_from_repository_job.rb index 4f27d76f0..74c9850c0 100644 --- a/app/jobs/destroy_project_from_repository_job.rb +++ b/app/jobs/destroy_project_from_repository_job.rb @@ -1,6 +1,10 @@ -class DestroyProjectFromRepositoryJob +class DestroyProjectFromRepositoryJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def self.perform(project, repository) + def perform_with_ar_connection(project_id, repository_id) + project = Project.find(project_id) + repository = Repository.find(repository_id) service = AbfWorkerService::Repository.new(repository) service.destroy_project!(project) end diff --git a/app/jobs/publish_task_manager_job.rb b/app/jobs/publish_task_manager_job.rb index a1cfc988c..4b4eb7421 100644 --- a/app/jobs/publish_task_manager_job.rb +++ b/app/jobs/publish_task_manager_job.rb @@ -1,11 +1,8 @@ -class PublishTaskManagerJob - @queue = :middle +class PublishTaskManagerJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :middle - def self.perform - PublishTaskManagerJob.new.perform - end - - def perform + def perform_with_ar_connection regenerate_metadata_for_software_center resign_repositories regenerate_metadata diff --git a/app/jobs/remove_outdated_items_job.rb b/app/jobs/remove_outdated_items_job.rb index 6cae5ab5e..5c470de35 100644 --- a/app/jobs/remove_outdated_items_job.rb +++ b/app/jobs/remove_outdated_items_job.rb @@ -1,7 +1,8 @@ -class RemoveOutdatedItemsJob - @queue = :low +class RemoveOutdatedItemsJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def self.perform + def perform_with_ar_connection log_file = Rails.root.join("log", "remove_outdated.log").to_s counter_bl = 0 BuildList.outdated.find_each(batch_size: 100) do |bl| diff --git a/app/jobs/run_extra_mass_builds_job.rb b/app/jobs/run_extra_mass_builds_job.rb index 00168ad83..65cd130ab 100644 --- a/app/jobs/run_extra_mass_builds_job.rb +++ b/app/jobs/run_extra_mass_builds_job.rb @@ -1,11 +1,8 @@ -class RunExtraMassBuildsJob - @queue = :low +class RunExtraMassBuildsJob < BaseActiveRecordJob + include Sidekiq::Worker + sidekiq_options :queue => :low - def self.perform - RunExtraMassBuildsJob.new.perform - end - - def perform + def perform_with_ar_connection MassBuild.where(status: MassBuild::BUILD_PENDING).find_each do |mb| next if mb.extra_mass_builds.blank? emb = MassBuild.where(status: MassBuild::SUCCESS, id: mb.extra_mass_builds).to_a diff --git a/app/mailers/feedback_mailer.rb b/app/mailers/feedback_mailer.rb index 362656185..c9150251d 100644 --- a/app/mailers/feedback_mailer.rb +++ b/app/mailers/feedback_mailer.rb @@ -6,7 +6,7 @@ class FeedbackMailer < ActionMailer::Base bcc: FBM_CONFIG['bcc'] default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url'] - include Resque::Mailer # send email async +# include Resque::Mailer # send email async def feedback_form_send(form_data) @data = Feedback.new(form_data) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index c70d7ff19..ef007bac9 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -4,7 +4,7 @@ class UserMailer < ActionMailer::Base default from: "\"#{APP_CONFIG['project_name']}\" <#{APP_CONFIG['do-not-reply-email']}>" default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url'] - include Resque::Mailer # send email async +# include Resque::Mailer # send email async def build_list_notification(build_list, user) set_locale user diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 6a921a27f..ef531c52c 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -169,10 +169,6 @@ class BuildList < ActiveRecord::Base state_machine :status, initial: :waiting_for_response do - #after_transition(on: [:place_build, :rerun_tests]) do |build_list, transition| - #build_list.add_job_to_abf_worker_queue if build_list.external_nodes.blank? - #end - after_transition on: :published, do: %i(set_version_and_tag actualize_packages) after_transition on: :publish, do: :set_publisher @@ -286,7 +282,6 @@ class BuildList < ActiveRecord::Base end later :publish, queue: :middle - later :add_job_to_abf_worker_queue, queue: :middle HUMAN_CONTAINER_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_publish, BUILD_PUBLISHED => :container_published, @@ -571,7 +566,7 @@ class BuildList < ActiveRecord::Base protected def create_container - Resque.enqueue(BuildLists::CreateContainerJob, id) + BuildLists::CreateContainerJob.perform_async(id) end def remove_container @@ -595,14 +590,14 @@ class BuildList < ActiveRecord::Base end def notify_users - unless mass_build_id - users = [user, publisher].compact.uniq.select{ |u| u.notifier.can_notify? && u.notifier.new_build? } + #unless mass_build_id + # users = [user, publisher].compact.uniq.select{ |u| u.notifier.can_notify? && u.notifier.new_build? } - users |= project.all_members(:notifier).select do |u| - u.notifier.can_notify? && u.notifier.new_associated_build? - end if project - users.each{ |u| UserMailer.build_list_notification(self, u).deliver } - end + # users |= project.all_members(:notifier).select do |u| + # u.notifier.can_notify? && u.notifier.new_associated_build? + # end if project + # users.each{ |u| UserMailer.build_list_notification(self, u).deliver } + #end end # notify_users def build_package(pkg_hash, package_type, prj) diff --git a/app/models/concerns/abf_worker_methods.rb b/app/models/concerns/abf_worker_methods.rb index bfe76de54..d3b4b9891 100644 --- a/app/models/concerns/abf_worker_methods.rb +++ b/app/models/concerns/abf_worker_methods.rb @@ -22,8 +22,8 @@ module AbfWorkerMethods end def add_job_to_abf_worker_queue - Resque.push( - worker_queue_with_priority, + Sidekiq::Client.push( + 'queue' => worker_queue_with_priority, 'class' => worker_queue_class, 'args' => [abf_worker_args] ) @@ -39,11 +39,8 @@ module AbfWorkerMethods end def destroy_from_resque_queue - Resque::Job.destroy( - worker_queue_with_priority, - worker_queue_class, - abf_worker_args - ) + #FIX THIS + 0 end def worker_queue_with_priority(prefix = true) diff --git a/app/models/concerns/empty_metadata.rb b/app/models/concerns/empty_metadata.rb index 0f8fa5927..88e0c6150 100644 --- a/app/models/concerns/empty_metadata.rb +++ b/app/models/concerns/empty_metadata.rb @@ -7,7 +7,7 @@ module EmptyMetadata def create_empty_metadata return if is_a?(Platform) && ( personal? || hidden? ) - Resque.enqueue(CreateEmptyMetadataJob, self.class.name, id) + CreateEmptyMetadataJob.perform_async(self.class.name, id) end end diff --git a/app/models/platform.rb b/app/models/platform.rb index 538219244..e989c035b 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -310,8 +310,8 @@ class Platform < ActiveRecord::Base end def notify_users - users = members.includes(:notifier).select{ |u| u.notifier.can_notify? } - users.each{ |u| UserMailer.metadata_regeneration_notification(self, u).deliver } + #users = members.includes(:notifier).select{ |u| u.notifier.can_notify? } + #users.each{ |u| UserMailer.metadata_regeneration_notification(self, u).deliver } end end diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index 1d9d7cbdc..1f9d90b08 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -27,7 +27,7 @@ class ProjectToRepository < ActiveRecord::Base protected def destroy_project_from_repository - DestroyProjectFromRepositoryJob.perform(project, repository) + DestroyProjectFromRepositoryJob.perform_async(project_id, repository_id) end def one_project_in_platform_repositories diff --git a/app/presenters/abf_worker_status_presenter.rb b/app/presenters/abf_worker_status_presenter.rb index 16d1560b3..74f6f9c35 100644 --- a/app/presenters/abf_worker_status_presenter.rb +++ b/app/presenters/abf_worker_status_presenter.rb @@ -38,10 +38,10 @@ class AbfWorkerStatusPresenter def get_status(*queues) status = {} - queues.each do |worker| - workers = Resque.workers.select{ |w| yield w, worker } - status[worker] = status_of_worker workers, worker - end + #queues.each do |worker| + # workers = Resque.workers.select{ |w| yield w, worker } + # status[worker] = status_of_worker workers, worker + #end status end diff --git a/app/services/abf_worker_service/container.rb b/app/services/abf_worker_service/container.rb index dee8813a5..c9ca325d2 100644 --- a/app/services/abf_worker_service/container.rb +++ b/app/services/abf_worker_service/container.rb @@ -15,8 +15,8 @@ module AbfWorkerService return end - Resque.push( - 'publish_worker', # Low priority + Sidekiq::Client.push( + 'queue' => 'publish_worker', # Low priority 'class' => 'AbfWorker::PublishWorker', 'args' => [{ id: build_list.id, diff --git a/app/services/abf_worker_service/platform_metadata.rb b/app/services/abf_worker_service/platform_metadata.rb index d59757d7f..c32ec9160 100644 --- a/app/services/abf_worker_service/platform_metadata.rb +++ b/app/services/abf_worker_service/platform_metadata.rb @@ -10,8 +10,8 @@ module AbfWorkerService def regenerate! return unless can_regenerate? - Resque.push( - 'publish_worker_default', + Sidekiq::Client.push( + 'queue' => 'publish_worker_default', 'class' => 'AbfWorker::PublishWorkerDefault', 'args' => [{ id: Time.now.to_i, diff --git a/app/services/abf_worker_service/repository.rb b/app/services/abf_worker_service/repository.rb index ec5ee0803..32b24765b 100644 --- a/app/services/abf_worker_service/repository.rb +++ b/app/services/abf_worker_service/repository.rb @@ -30,8 +30,8 @@ module AbfWorkerService def resign!(repository_status) return if repository.repo_lock_file_exists? - Resque.push( - 'publish_worker_default', + Sidekiq::Client.push( + 'queue' => 'publish_worker_default', 'class' => "AbfWorker::PublishWorkerDefault", 'args' => [{ id: repository.id, diff --git a/app/services/abf_worker_service/repository_metadata.rb b/app/services/abf_worker_service/repository_metadata.rb index 880f2fa5b..b8e7129d6 100644 --- a/app/services/abf_worker_service/repository_metadata.rb +++ b/app/services/abf_worker_service/repository_metadata.rb @@ -18,8 +18,8 @@ module AbfWorkerService system "mkdir -p #{platform_path}" end - Resque.push( - 'publish_worker_default', + Sidekiq::Client.push( + 'queue' => 'publish_worker_default', 'class' => 'AbfWorker::PublishWorkerDefault', 'args' => [{ id: Time.now.to_i, diff --git a/app/services/abf_worker_service/rpm.rb b/app/services/abf_worker_service/rpm.rb index 85cf3a90a..249ee5929 100644 --- a/app/services/abf_worker_service/rpm.rb +++ b/app/services/abf_worker_service/rpm.rb @@ -206,8 +206,8 @@ module AbfWorkerService end def push(options) - Resque.push( - 'publish_worker_default', + Sidekiq::Client.push( + 'queue' => 'publish_worker_default', 'class' => 'AbfWorker::PublishWorkerDefault', 'args' => [options] ) diff --git a/app/views/layouts/loading.html.slim b/app/views/layouts/loading.html.slim deleted file mode 100644 index 35ab6f610..000000000 --- a/app/views/layouts/loading.html.slim +++ /dev/null @@ -1,2 +0,0 @@ -div ng-if="false" - \ No newline at end of file diff --git a/app/views/layouts/sessions.html.slim b/app/views/layouts/sessions.html.slim index edefc7554..e439485d3 100644 --- a/app/views/layouts/sessions.html.slim +++ b/app/views/layouts/sessions.html.slim @@ -9,50 +9,37 @@ html = auto_discovery_link_tag :atom, atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token), title: t("layout.atom_link_tag_title", nickname: current_user.uname, app_name: APP_CONFIG['project_name']) script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js" type="text/javascript" link href='//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' rel='stylesheet' + link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous" link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css' == stylesheet_link_tag 'new_application', cache: 'application' body[ ng-app='RosaABF' ng-controller='RosaABFController' ng-strict-di='' ng-init="init('#{I18n.locale}', #{!!current_user.try(:sound_notifications)})" ng-cloak="true"] - .page-wrapper.open + .page-wrapper ng-class="{'open': toggle}" .sidebar-wrapper ul.sidebar li.sidebar-main - a href="/" - = link_to image_tag('logo-mini.png', alt: 'ABF'), root_path + a ng-click="toggleSidebar()" + = image_tag('logo-mini.png', alt: 'ABF') + span class="menu-icon glyphicon glyphicon-transfer" == render 'layouts/menu/new_top' + == render 'layouts/menu/new_bottom' .content-wrapper .page-content - .row.header - .col-md-12 - .user.pull-right - - if current_user - .item.dropdown(uib-dropdown) - a(uib-dropdown-toggle) - = image_tag avatar_url(current_user), alt: 'avatar' - ul.dropdown-menu.dropdown-menu-right - li.link= link_to current_user.uname, current_user - li.link= link_to t('layout.settings.label'), profile_settings_path - li.divider - li.link= link_to t('layout.logout'), destroy_user_session_path, method: :delete - - else - ul.nav.navbar-nav - li= link_to t('layout.devise.shared_links.sign_up'), new_user_registration_path - li= link_to t('layout.devise.shared_links.sign_in'), new_user_session_path - .meta - .page == yield :submenu if content_for?(:submenu) == render 'layouts/noscript' == render "layouts/flashes" == yield + + script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js" type="text/javascript" script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js" type="text/javascript" - script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-resource.js" type="text/javascript" - script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-cookies.js" type="text/javascript" - script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-sanitize.js" type="text/javascript" - script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.5/ui-bootstrap-tpls.js" type="text/javascript" + script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-resource.min.js" type="text/javascript" + script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-cookies.min.js" type="text/javascript" + script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-sanitize.min.js" type="text/javascript" + script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.5/ui-bootstrap-tpls.min.js" type="text/javascript" script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous" == javascript_include_tag 'new_application', cache: 'application' == yield :additional_scripts if content_for?(:additional_scripts) diff --git a/app/views/platforms/product_build_lists/show.html.slim b/app/views/platforms/product_build_lists/show.html.slim index 298e92a6d..28274af22 100644 --- a/app/views/platforms/product_build_lists/show.html.slim +++ b/app/views/platforms/product_build_lists/show.html.slim @@ -7,118 +7,119 @@ - product = pbl.product - platform = product.platform -.row ng-controller='ProductBuildListController' ng-init=("init("+pbl.id.to_s+")") - .col-md-6 - rd-widget - rd-widget-header title=t('layout.product_build_lists.main_data') - rd-widget-body class="no-padding" - table.table.table-condensed - tr - td - = t('activerecord.attributes.product_build_list.id') - td - = pbl.id +div ng-init=("init("+pbl.id.to_s+")") ng-controller='ProductBuildListController' + .row + .col-md-6 + rd-widget + rd-widget-header title=t('layout.product_build_lists.main_data') + rd-widget-body class="no-padding" + table.table.table-condensed + tr + td + = t('activerecord.attributes.product_build_list.id') + td + = pbl.id - tr - td - = t('activerecord.attributes.product_build_list.status') - td - | {{pbl.human_status}} + tr + td + = t('activerecord.attributes.product_build_list.status') + td + | {{pbl.human_status}} - - if pbl.user - tr - td - = t('activerecord.attributes.product_build_list.user') - td - = link_to pbl.user.try(:fullname), pbl.user + - if pbl.user + tr + td + = t('activerecord.attributes.product_build_list.user') + td + = link_to pbl.user.try(:fullname), pbl.user + + tr + td + = t('activerecord.attributes.product_build_list.product') + td + = link_to pbl.product.name, platform_product_path(platform, product) tr td - = t('activerecord.attributes.product_build_list.product') + = t('activerecord.attributes.product_build_list.project') td - = link_to pbl.product.name, platform_product_path(platform, product) + = link_to pbl.project.name_with_owner, project_build_lists_path(pbl.project) - tr - td - = t('activerecord.attributes.product_build_list.project') - td - = link_to pbl.project.name_with_owner, project_build_lists_path(pbl.project) - - tr - td - = t('activerecord.attributes.product_build_list.project_version') - td - = product_build_list_version_link(pbl, true) - - tr - td - = t('activerecord.attributes.product_build_list.main_script') - td - = pbl.main_script - - tr - td - = t('activerecord.attributes.product_build_list.params') - td - = pbl.params - - tr - td - = t('activerecord.attributes.product_build_list.time_living') - td - = pbl.time_living / 60 - - tr - td - = t('activerecord.attributes.product_build_list.autostarted') - td - = t("layout.#{pbl.autostarted}_") - - tr - td - = t('activerecord.attributes.product_build_list.notified_at') - td - | {{pbl.notified_at}} - - - if policy(pbl).update? - tr ng-show="pbl.status == #{ ProductBuildList::BUILD_COMPLETED }" + tr td - = t('activerecord.attributes.product_build_list.not_delete') + = t('activerecord.attributes.product_build_list.project_version') td - = select_tag 'not_delete', - options_for_select(product_build_list_delete_options), - { ng_model: "pbl.not_delete", ng_change: 'updateStatus()'} - .row.alert.alert-danger.top-space ng-hide='pbl.not_delete != "false"' - - days = pbl.autostarted? ? ProductBuildList::LIVE_TIME : ProductBuildList::MAX_LIVE_TIME - - days = (pbl.created_at.to_date - days.ago.to_date).to_i - - if days > 1 - = t('layout.product_build_lists.will_be_removed_n_days', n: days) - - else - = t('layout.product_build_lists.will_be_removed_today') + = product_build_list_version_link(pbl, true) - - if policy(pbl).cancel? || policy(pbl).destroy? - rd-widget-footer ng-show="pbl.can_cancel || pbl.can_destroy" - - if policy(pbl).cancel? - a.btn.btn-warning[ - href=cancel_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) - data-method = 'put' - data-confirm = t('layout.confirm') - ng-show = 'pbl.can_cancel' ] - = t('layout.build_lists.cancel') - |   + tr + td + = t('activerecord.attributes.product_build_list.main_script') + td + = pbl.main_script - - if policy(pbl).destroy? - a.btn.btn-danger[ - href=platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) - data-method = 'delete' - data-confirm = t('layout.confirm') - ng-show = 'pbl.can_destroy' ] - = t('layout.product_build_lists.delete') - .col-md-6 - = render 'shared/build_results', subject: pbl + tr + td + = t('activerecord.attributes.product_build_list.params') + td + = pbl.params -.row ng-show="pbl.status == #{ProductBuildList::BUILD_STARTED}" - .col-md-12 - = render 'shared/log', { build_started: true, get_log_path: log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) } + tr + td + = t('activerecord.attributes.product_build_list.time_living') + td + = pbl.time_living / 60 + + tr + td + = t('activerecord.attributes.product_build_list.autostarted') + td + = t("layout.#{pbl.autostarted}_") + + tr + td + = t('activerecord.attributes.product_build_list.notified_at') + td + | {{pbl.notified_at}} + + - if policy(pbl).update? + tr ng-show="pbl.status == #{ ProductBuildList::BUILD_COMPLETED }" + td + = t('activerecord.attributes.product_build_list.not_delete') + td + = select_tag 'not_delete', + options_for_select(product_build_list_delete_options), + { ng_model: "pbl.not_delete", ng_change: 'updateStatus()'} + .row.alert.alert-danger.top-space ng-hide='pbl.not_delete != "false"' + - days = pbl.autostarted? ? ProductBuildList::LIVE_TIME : ProductBuildList::MAX_LIVE_TIME + - days = (pbl.created_at.to_date - days.ago.to_date).to_i + - if days > 1 + = t('layout.product_build_lists.will_be_removed_n_days', n: days) + - else + = t('layout.product_build_lists.will_be_removed_today') + + - if policy(pbl).cancel? || policy(pbl).destroy? + rd-widget-footer ng-show="pbl.can_cancel || pbl.can_destroy" + - if policy(pbl).cancel? + a.btn.btn-warning[ + href=cancel_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) + data-method = 'put' + data-confirm = t('layout.confirm') + ng-show = 'pbl.can_cancel' ] + = t('layout.build_lists.cancel') + |   + + - if policy(pbl).destroy? + a.btn.btn-danger[ + href=platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) + data-method = 'delete' + data-confirm = t('layout.confirm') + ng-show = 'pbl.can_destroy' ] + = t('layout.product_build_lists.delete') + .col-md-6 + = render 'shared/build_results', subject: pbl + + .row.top-space ng-show="pbl.status == #{ProductBuildList::BUILD_STARTED}" + .col-md-12 + = render 'shared/log', { build_started: true, get_log_path: log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) } diff --git a/config/initializers/1_resque.rb b/config/initializers/1_resque.rb index 0c51c5ef6..f0bc159fb 100644 --- a/config/initializers/1_resque.rb +++ b/config/initializers/1_resque.rb @@ -1,15 +1,15 @@ -require 'resque/server' -require 'resque/status_server' -require 'resque_scheduler' -require 'resque_scheduler/server' +#require 'resque/server' +#require 'resque/status_server' +#require 'resque_scheduler' +#require 'resque_scheduler/server' -::ResqueServer = ::Resque::Server # need for CanCan +#::ResqueServer = ::Resque::Server # need for CanCan -Resque::Mailer.default_queue_name = :notification -Resque::Mailer.excluded_environments = [:test] +#Resque::Mailer.default_queue_name = :notification +#Resque::Mailer.excluded_environments = [:test] -unless Rails.env.test? - PerformLater.config.enabled = true # this will default to false if unset -end +#unless Rails.env.test? +# PerformLater.config.enabled = true # this will default to false if unset +#end -Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds \ No newline at end of file +#Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds \ No newline at end of file diff --git a/config/initializers/1_sidekiq.rb b/config/initializers/1_sidekiq.rb new file mode 100644 index 000000000..294809f4f --- /dev/null +++ b/config/initializers/1_sidekiq.rb @@ -0,0 +1,11 @@ +require 'sidekiq/scheduler' + +Kiqit.config.enabled = true + +Sidekiq.configure_server do |config| + config.on(:startup) do + Sidekiq.schedule = YAML + .load_file(File.expand_path('../../../config/schedule.yml', __FILE__)) + Sidekiq::Scheduler.reload_schedule! + end +end diff --git a/config/routes.rb b/config/routes.rb index 9366fe9c2..606c9a401 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,6 @@ +require 'sidekiq/web' +require 'sidekiq-scheduler/web' + Rails.application.routes.draw do # ActiveAdmin routes. @@ -5,7 +8,7 @@ Rails.application.routes.draw do namespace :admin do constraints Rosa::Constraints::AdminAccess do - mount Resque::Server => 'resque' + mount Sidekiq::Web => 'sidekiq' end end diff --git a/config/resque_schedule.yml b/config/schedule.yml similarity index 100% rename from config/resque_schedule.yml rename to config/schedule.yml diff --git a/doc/state_machines/BuildList_container_status.png b/doc/state_machines/BuildList_container_status.png new file mode 100644 index 000000000..2d6d72a05 Binary files /dev/null and b/doc/state_machines/BuildList_container_status.png differ diff --git a/doc/state_machines/BuildList_status.png b/doc/state_machines/BuildList_status.png new file mode 100644 index 000000000..33dc2160d Binary files /dev/null and b/doc/state_machines/BuildList_status.png differ diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake deleted file mode 100644 index 76cafb58a..000000000 --- a/lib/tasks/resque.rake +++ /dev/null @@ -1,23 +0,0 @@ -namespace :resque do - desc 'Stop all Resque workers' - task stop_workers: :environment do - pids = [] - Resque.workers.each do |worker| - pids << worker.to_s.split(/:/).second - end - system("kill -QUIT #{pids.join(' ')}") if pids.size > 0 - end - - # This fixes connection fail with Postgres server on new fork: - task setup: :environment do - Resque.after_fork do - Resque.redis.client.reconnect - end - Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } - end - - task scheduler_setup: :environment do - Resque.schedule = YAML.load_file(Rails.root.join('config', 'resque_schedule.yml')) - end - -end