From 63c50aee7b898c35fdacea4fabd875c5ba656eb0 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Fri, 8 Jun 2012 20:19:19 +0300 Subject: [PATCH 1/6] Apply task for sprm import. Refs #112 --- lib/tasks/import.rake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 1649e395a..64d5b94bd 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -27,6 +27,31 @@ namespace :import do say 'DONE' end + desc 'Import SRPMs as projects' + task :srpm => :environment do + base = ENV['BASE'] || '/share/alt_repos/rsync' + list = ENV['LIST'] #|| 'https://dl.dropbox.com/u/984976/alt_import.txt' + mask = ENV['MASK'] || '*.src.rpm' + owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'altlinux') + platform = Platform.find_by_name!(ENV['PLATFORM'] || 'altlinux5') + repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main') + say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'." + repo.project_to_repositories.clear if agree "Clear destination repo #{platform.name}/#{repo.name}?" + (list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |path| + print "Processing '#{path}'..." + if name = `rpm -q --qf '[%{Name}]' -p #{path}` and $?.success? and name.present? + p = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id) + p.import_srpm(path, platform.name) + repo.projects << p + print "Ok! - #{p.name}" + else + print 'Fail!' + end + puts + end + say 'DONE' + end + namespace :sync do desc "Sync all repos" task :all do From b0073381e894a5071228a96b2adce456be5b9f5a Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Fri, 8 Jun 2012 21:01:33 +0300 Subject: [PATCH 2/6] Add run example. Refs #112 --- lib/tasks/import.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 64d5b94bd..b031980bf 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -27,6 +27,7 @@ namespace :import do say 'DONE' end + # bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main > log/srpm_naulinux.log desc 'Import SRPMs as projects' task :srpm => :environment do base = ENV['BASE'] || '/share/alt_repos/rsync' From c038b255a8d1b33ea4f812bb289d2fd4e0f50ad1 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Fri, 8 Jun 2012 21:20:02 +0300 Subject: [PATCH 3/6] Allow dot at platform name. Refs #207 --- app/models/platform.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index 27cc90d70..33821f930 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -21,7 +21,7 @@ class Platform < ActiveRecord::Base validates :description, :presence => true validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES} - validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } + validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\.]+$/ } validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready From fac3335df431ffcfd577885a3dae66e90e8ffa42 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 9 Jun 2012 11:12:23 +0400 Subject: [PATCH 4/6] [refs #510] Fix resque link into the menu --- app/views/layouts/menu/_top.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/menu/_top.html.haml b/app/views/layouts/menu/_top.html.haml index ac99cc27f..91539b90f 100644 --- a/app/views/layouts/menu/_top.html.haml +++ b/app/views/layouts/menu/_top.html.haml @@ -6,4 +6,4 @@ - if current_user.try(:admin?) and which_menu == 'top_menu' %li= link_to t('admins_menu_header'), admin_users_path, :class => top_menu_class('admin') - if current_user.try(:admin?) and which_menu == 'admins_menu' - %li= link_to t('resque_server'), admin_resque_server_path, :class => top_menu_class('admin') + %li= link_to t('resque_server'), admin_resque_server_path From f37e0e54a3c8dbb77966dd4267f5d26be28a718e Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 9 Jun 2012 16:52:29 +0400 Subject: [PATCH 5/6] [refs #510] Replace dj with resque --- Gemfile | 2 +- Gemfile.lock | 6 --- .../platforms/platforms_controller.rb | 2 +- .../projects/build_lists_controller.rb | 2 +- app/controllers/projects/wiki_controller.rb | 2 +- app/mailers/user_mailer.rb | 4 ++ app/models/activity_feed_observer.rb | 14 ++++--- app/models/build_list.rb | 4 ++ app/models/mass_build.rb | 6 ++- app/models/platform.rb | 7 +++- app/models/project.rb | 17 ++------- app/models/repository.rb | 6 ++- config/deploy.rb | 6 --- config/production.pill | 11 ------ lib/modules/models/resque_async_methods.rb | 32 ++++++++++++++++ lib/recipes/bluepill.rb | 7 ---- lib/recipes/delayed_job.rb | 37 ------------------- lib/tasks/hook.rake | 2 +- 18 files changed, 72 insertions(+), 95 deletions(-) create mode 100644 lib/modules/models/resque_async_methods.rb delete mode 100644 lib/recipes/delayed_job.rb diff --git a/Gemfile b/Gemfile index 0b4ded308..c2ed09aa6 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'cancan', '~> 1.6.7' gem 'ancestry', '~> 1.2.5' gem 'paperclip', '~> 3.0.2' -gem 'delayed_job_active_record', '~> 0.3.2' +#gem 'delayed_job_active_record', '~> 0.3.2' gem 'resque' gem 'russian', '~> 0.6.0' gem 'highline', '~> 1.6.11' diff --git a/Gemfile.lock b/Gemfile.lock index 50cbcd2a7..ebb8a9ebf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,11 +96,6 @@ GEM compass (~> 0.12.0) creole (0.4.2) daemons (1.1.6) - delayed_job (3.0.2) - activesupport (~> 3.0) - delayed_job_active_record (0.3.2) - activerecord (> 2.1.0) - delayed_job (~> 3.0.0) devise (2.0.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) @@ -340,7 +335,6 @@ DEPENDENCIES compass-rails (~> 1.0.1) creole daemons (= 1.1.6) - delayed_job_active_record (~> 0.3.2) devise (~> 2.0.4) diff-display (~> 0.0.1) factory_girl_rails (~> 3.1.0) diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index 50aacb986..6afc43b9a 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -98,7 +98,7 @@ class Platforms::PlatformsController < Platforms::BaseController end def destroy - @platform.delay.destroy if @platform + @platform.async(:destroy) if @platform flash[:notice] = t("flash.platform.destroyed") redirect_to platforms_path diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 2f3629532..e488ca9f8 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -132,7 +132,7 @@ class Projects::BuildListsController < Projects::BaseController render :nothing => true, :status => 200 - @build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish? + @build_list.async(:publish) if @build_list.auto_publish # && @build_list.can_publish? end def circle_build diff --git a/app/controllers/projects/wiki_controller.rb b/app/controllers/projects/wiki_controller.rb index c56d73dc9..65e3cac9b 100644 --- a/app/controllers/projects/wiki_controller.rb +++ b/app/controllers/projects/wiki_controller.rb @@ -258,7 +258,7 @@ class Projects::WikiController < Projects::BaseController # @committer.after_commit do |committer, sha1| # here goes callback for notification # end - ActivityFeedObserver.instance.after_create(@committer).delay + ActivityFeedObserver.instance.async(:after_create, @committer) end @committer end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 82b8be5b8..9f1c3535e 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -3,6 +3,10 @@ class UserMailer < ActionMailer::Base default :from => APP_CONFIG['do-not-reply-email'] + include Modules::Models::ResqueAsyncMethods + + @queue = :notifications + def new_user_notification(user) @user = user mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format| diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 023c1e9f6..defb8e6b9 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -2,6 +2,10 @@ class ActivityFeedObserver < ActiveRecord::Observer observe :issue, :comment, :user, :build_list + include Modules::Models::ResqueAsyncMethods + + @queue = :notifications + def after_create(record) case record.class.to_s when 'User' @@ -15,7 +19,7 @@ class ActivityFeedObserver < ActiveRecord::Observer recipients = record.collect_recipient_ids recipients.each do |recipient_id| recipient = User.find(recipient_id) - UserMailer.delay.new_issue_notification(record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue + UserMailer.async(:new_issue_notification, record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', @@ -25,7 +29,7 @@ class ActivityFeedObserver < ActiveRecord::Observer end if record.assignee_id_changed? - UserMailer.delay.issue_assign_notification(record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify + UserMailer.async(:new_issue_notification, record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify ActivityFeed.create( :user => record.user, :kind => 'issue_assign_notification', @@ -39,7 +43,7 @@ class ActivityFeedObserver < ActiveRecord::Observer subscribes = record.commentable.subscribes subscribes.each do |subscribe| if record.user_id != subscribe.user_id - UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) + UserMailer.async(:new_comment_notification, record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_notification', @@ -57,7 +61,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ( (subscribe.project.owner?(subscribe.user) && subscribe.user.notifier.new_comment_commit_repo_owner) or (subscribe.user.commentor?(record.commentable) && subscribe.user.notifier.new_comment_commit_commentor) or (subscribe.user.committer?(record.commentable) && subscribe.user.notifier.new_comment_commit_owner) ) - UserMailer.delay.new_comment_notification(record, subscribe.user) + UserMailer.async(:new_comment_notification, record, subscribe.user) end ActivityFeed.create( :user => subscribe.user, @@ -122,7 +126,7 @@ class ActivityFeedObserver < ActiveRecord::Observer case record.class.to_s when 'Issue' if record.assignee_id && record.assignee_id_changed? - UserMailer.delay.issue_assign_notification(record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify + UserMailer.async(:issue_assign_notification, record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify ActivityFeed.create( :user => record.assignee, :kind => 'issue_assign_notification', diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 3cee985fb..b5594e04d 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -100,6 +100,10 @@ class BuildList < ActiveRecord::Base after_create :place_build after_destroy :delete_container + include Modules::Models::ResqueAsyncMethods + + @queue = :clone_and_build + def self.human_status(status) I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}") end diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 1afe9a99b..ee7570012 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -12,6 +12,10 @@ class MassBuild < ActiveRecord::Base after_create :build_all + include Modules::Models::ResqueAsyncMethods + + @queue = :clone_and_build + def initialize(args = nil) super @@ -24,7 +28,7 @@ class MassBuild < ActiveRecord::Base # ATTENTION: repositories and arches must be set before calling this method! def build_all - platform.delay.build_all( + platform.async(:build_all, :mass_build_id => self.id, :user => self.user, :repositories => self.repositories, diff --git a/app/models/platform.rb b/app/models/platform.rb index 33821f930..c905f0bf5 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -47,6 +47,9 @@ class Platform < ActiveRecord::Base attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type include Modules::Models::Owner + include Modules::Models::ResqueAsyncMethods + + @queue = :clone_and_build def urpmi_list(host, pair = nil) blank_pair = {:login => 'login', :pass => 'password'} @@ -118,7 +121,7 @@ class Platform < ActiveRecord::Base def full_clone(attrs = {}) base_clone(attrs).tap do |c| - with_skip {c.save} and c.clone_relations(self) and c.delay.xml_rpc_clone + with_skip {c.save} and c.clone_relations(self) and c.async(:xml_rpc_clone) end end @@ -172,7 +175,7 @@ class Platform < ActiveRecord::Base begin p.build_for(self, user, arch, auto_publish, mass_build_id) rescue RuntimeError, Exception - p.delay.build_for(self, user, arch, auto_publish, mass_build_id) + p.async(:build_for, self, user, arch, auto_publish, mass_build_id) end end end diff --git a/app/models/project.rb b/app/models/project.rb index 61a0f10a9..0d7d91e48 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -54,20 +54,9 @@ class Project < ActiveRecord::Base has_attached_file :srpm include Modules::Models::Owner + include Modules::Models::ResqueAsyncMethods - @queue = :fork_and_import - - # This will be called by a worker when a job needs to be processed - def self.perform(id, method, *args) - find(id).send(method, *args) - end - - # We can pass this any Repository instance method that we want to - # run later. - def async(method, *args) - Resque.enqueue(Project, id, method, *args) - end - + @queue = :fork_import_hook def to_param name @@ -305,7 +294,7 @@ class Project < ActiveRecord::Base hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) File.open(hook, 'a') do |f| - s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay(:queue => \\\"hook\\\").process_hook(\\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\"" + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.async(:process_hook, \\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\"" s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) diff --git a/app/models/repository.rb b/app/models/repository.rb index 2fd58e3f6..503ce4978 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -16,6 +16,10 @@ class Repository < ActiveRecord::Base attr_accessible :name, :description attr_readonly :name, :platform_id + include Modules::Models::ResqueAsyncMethods + + @queue = :clone_and_build + def base_clone(attrs = {}) dup.tap do |c| c.platform_id = nil @@ -32,7 +36,7 @@ class Repository < ActiveRecord::Base def full_clone(attrs = {}) base_clone(attrs).tap do |c| - with_skip {c.save} and c.delay.clone_relations(self) + with_skip {c.save} and c.async(:clone_relations, self) end end diff --git a/config/deploy.rb b/config/deploy.rb index 2e92a2060..5404bf5a3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -36,7 +36,6 @@ set :deploy_via, :remote_cache require './lib/recipes/nginx' require './lib/recipes/unicorn' #require './lib/recipes/bluepill' -require './lib/recipes/delayed_job' set :workers_count, 2 @@ -92,11 +91,6 @@ after "deploy:setup", "deploy:symlink_pids" #after "deploy:start", "bluepill:start" #after "deploy:stop", "bluepill:stop" -# DJ -after "deploy:stop", "delayed_job:stop" -after "deploy:start", "delayed_job:start" -after "deploy:restart", "delayed_job:restart" - # Resque after "deploy:stop", "resque:stop" after "deploy:start", "resque:start" diff --git a/config/production.pill b/config/production.pill index 8e36cdbce..4047c5aa6 100644 --- a/config/production.pill +++ b/config/production.pill @@ -4,17 +4,6 @@ app_name = ENV['APP_NAME'] || 'rosa_build' Bluepill.application(app_name, :log_file => "/srv/rosa_build/shared/log/bluepill.log") do |app| app.uid = app.gid = 'rosa' app.working_dir = "/srv/#{app_name}/current" - #%w(hook default).each do |queue| - # app.process("delayed_job_#{queue}_queue") do |process| - # process.start_grace_time = 10.seconds - # process.stop_grace_time = 10.seconds - # process.restart_grace_time = 10.seconds - - # process.start_command = "/usr/bin/env ruby script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids start" - # process.stop_command = "/usr/bin/env ruby script/delayed_job --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids stop" - # process.pid_file = File.join(app.working_dir, 'tmp', "#{queue}_pids", 'delayed_job.pid') - # end - #end app.process("resque") do |process| process.group = "resque" diff --git a/lib/modules/models/resque_async_methods.rb b/lib/modules/models/resque_async_methods.rb new file mode 100644 index 000000000..fe3fef009 --- /dev/null +++ b/lib/modules/models/resque_async_methods.rb @@ -0,0 +1,32 @@ +# -*- encoding : utf-8 -*- +module Modules + module Models + module ResqueAsyncMethods + extend ActiveSupport::Concern + + included do + # We can pass this any Repository instance method that we want to + # run later. + def async(method, *args) + Resque.enqueue(self.class, id, method, *args) + end + end + + module ClassMethods + # This will be called by a worker when a job needs to be processed + def perform(id, method, *args) + unless id.nil? + find(id).send(method, *args) + else + send(method, *args) + end + end + + def async(method, *args) + Resque.enqueue(self, nil, method, *args) + end + end + end + end +end + diff --git a/lib/recipes/bluepill.rb b/lib/recipes/bluepill.rb index b1ad43628..979f83af2 100644 --- a/lib/recipes/bluepill.rb +++ b/lib/recipes/bluepill.rb @@ -23,13 +23,6 @@ Capistrano::Configuration.instance(:must_exist).load do task :status, :roles => [:app] do run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status" end - - #desc "Restart DJ processes" - #task :restart_dj, :roles => [:app] do - # %w(fork import hook default).each do |queue| - # run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job_#{queue}_queue" - # end - #end end desc "Start a bluepill process and load a config" diff --git a/lib/recipes/delayed_job.rb b/lib/recipes/delayed_job.rb deleted file mode 100644 index 1db2ba6df..000000000 --- a/lib/recipes/delayed_job.rb +++ /dev/null @@ -1,37 +0,0 @@ -# -*- encoding : utf-8 -*- -Capistrano::Configuration.instance(:must_exist).load do - namespace :delayed_job do - def dj_queues - %w(hook default) - end - - def rails_env - fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : '' - end - - def roles - fetch(:delayed_job_server_role, :app) - end - - desc "Stop the delayed_job process" - task :stop, :roles => lambda { roles } do - dj_queues.each do |queue| - run "cd #{current_path};#{rails_env} script/delayed_job --pid-dir=#{shared_path}/pids/#{queue} stop" - end - end - - desc "Start the delayed_job process" - task :start, :roles => lambda { roles } do - dj_queues.each do |queue| - run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} start" - end - end - - desc "Restart the delayed_job process" - task :restart, :roles => lambda { roles } do - dj_queues.each do |queue| - run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} restart" - end - end - end -end diff --git a/lib/tasks/hook.rake b/lib/tasks/hook.rake index cd3841fba..31dfc5c88 100644 --- a/lib/tasks/hook.rake +++ b/lib/tasks/hook.rake @@ -6,7 +6,7 @@ namespace :hook do hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook) File.open(hook, 'a') do |f| - s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay(:queue => \\\"hook\\\").process_hook(\\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\"" + s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.async(:process_hook, \\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\"" s << " > /dev/null 2>&1" if is_production s << "\ndone\n" f.write(s) From cdf2316a76a39beb4ad2edad4e7d2d181665fdef Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 9 Jun 2012 18:53:00 +0400 Subject: [PATCH 6/6] [refs #510] Add queues to capistrano deploy. Add 4 workers to config --- config/deploy.rb | 2 +- lib/recipes/resque.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 5404bf5a3..1af5b469b 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -37,7 +37,7 @@ require './lib/recipes/nginx' require './lib/recipes/unicorn' #require './lib/recipes/bluepill' -set :workers_count, 2 +set :workers_count, 4 require './lib/recipes/resque' diff --git a/lib/recipes/resque.rb b/lib/recipes/resque.rb index d12bfffd5..ae98eb72d 100644 --- a/lib/recipes/resque.rb +++ b/lib/recipes/resque.rb @@ -24,7 +24,7 @@ Capistrano::Configuration.instance(:must_exist).load do end def start_workers - run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_and_import #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers" + run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_import_hook,clone_and_build,notifications #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers" end end end