Update rails and gems. Redo resque jobs enqueue and perform through plugins. Redo emails async sending. Redo hook process. Refactor and code cleanup. Refs #510

This commit is contained in:
Pavel Chipiga 2012-06-16 21:27:46 +03:00
parent 76979c6b83
commit b47b4ec075
23 changed files with 205 additions and 219 deletions

28
Gemfile
View File

@ -1,6 +1,6 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '3.2.3' #, :git => 'git://github.com/rails/rails.git' gem 'rails', '3.2.6' #, :git => 'git://github.com/rails/rails.git'
gem 'pg', '~> 0.13.2' gem 'pg', '~> 0.13.2'
# gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1' # gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1'
@ -12,15 +12,15 @@ gem 'omniauth', '~> 1.0.3'
gem 'omniauth-openid', '~> 1.0.1' gem 'omniauth-openid', '~> 1.0.1'
gem 'cancan', '~> 1.6.7' gem 'cancan', '~> 1.6.7'
gem 'ancestry', '~> 1.2.5' gem 'ancestry', '~> 1.3.0'
gem 'paperclip', '~> 3.0.2' gem 'paperclip', '~> 3.0.4'
#gem 'delayed_job_active_record', '~> 0.3.2' gem 'resque', '~> 1.20.0'
gem 'resque' gem 'resque-status', '~> 0.3.3'
gem 'resque_mailer', '~> 2.1.0'
gem 'perform_later', '~> 1.3.0' # should be after resque_mailer
gem 'russian', '~> 0.6.0' gem 'russian', '~> 0.6.0'
gem 'highline', '~> 1.6.11' gem 'highline', '~> 1.6.11'
gem 'jbuilder'
# gem 'rugged', '~> 0.16.0' # gem 'rugged', '~> 0.16.0'
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http' gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
gem "grit", :git => 'git://github.com/warpc/grit.git' #, :path => '~/Sites/code/grit' gem "grit", :git => 'git://github.com/warpc/grit.git' #, :path => '~/Sites/code/grit'
@ -36,11 +36,12 @@ gem 'rdiscount'
gem 'RedCloth' gem 'RedCloth'
gem 'wikicloth' gem 'wikicloth'
gem 'unicorn', '~> 4.2.1', :platforms => [:mri, :rbx] gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', :platforms => :jruby gem 'trinidad', '~> 1.0.2', :platforms => :jruby
gem 'newrelic_rpm', '~> 3.3.3', :platforms => [:mri, :rbx] gem 'newrelic_rpm', '~> 3.3.5', :platforms => [:mri, :rbx]
gem 'whenever', '~> 0.7.3', :require => false gem 'whenever', '~> 0.7.3', :require => false
gem 'jbuilder', '~> 0.4.0'
gem 'rails3-jquery-autocomplete', '~> 1.0.7' gem 'rails3-jquery-autocomplete', '~> 1.0.7'
gem 'will_paginate', '~> 3.0.3' gem 'will_paginate', '~> 3.0.3'
gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags' gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags'
@ -52,16 +53,15 @@ gem 'rails-backbone', '~> 0.7.2'
group :assets do group :assets do
gem 'sass-rails', '~> 3.2.5' gem 'sass-rails', '~> 3.2.5'
gem 'coffee-rails', '~> 3.2.2' gem 'coffee-rails', '~> 3.2.2'
gem 'compass-rails', '~> 1.0.1' gem 'compass-rails', '~> 1.0.2'
gem 'uglifier', '~> 1.2.4' gem 'uglifier', '~> 1.2.4'
gem 'therubyracer', '~> 0.10.1', :platforms => [:mri, :rbx] gem 'therubyracer', '~> 0.10.1', :platforms => [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
end end
group :production do group :production do
gem "airbrake", '~> 3.0.9' gem "airbrake", '~> 3.1.1'
gem 'bluepill', '~> 0.0.60', :require => false gem 'bluepill', '~> 0.0.60', :require => false
gem 'daemons', '1.1.6' # Try to upgrade 1.1.8 to avoid tons DJ bugs?
end end
group :development do group :development do
@ -77,8 +77,8 @@ group :development do
end end
group :test do group :test do
gem 'rspec-rails', '~> 2.9.0', :group => 'development' gem 'rspec-rails', '~> 2.10.1', :group => 'development'
gem 'factory_girl_rails', '~> 3.1.0' gem 'factory_girl_rails', '~> 3.4.0'
gem 'rr', '~> 1.0.4' gem 'rr', '~> 1.0.4'
gem 'shoulda' gem 'shoulda'
end end

View File

@ -25,40 +25,40 @@ GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
RedCloth (4.2.9) RedCloth (4.2.9)
actionmailer (3.2.3) actionmailer (3.2.6)
actionpack (= 3.2.3) actionpack (= 3.2.6)
mail (~> 2.4.4) mail (~> 2.4.4)
actionpack (3.2.3) actionpack (3.2.6)
activemodel (= 3.2.3) activemodel (= 3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
builder (~> 3.0.0) builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
journey (~> 1.0.1) journey (~> 1.0.1)
rack (~> 1.4.0) rack (~> 1.4.0)
rack-cache (~> 1.2) rack-cache (~> 1.2)
rack-test (~> 0.6.1) rack-test (~> 0.6.1)
sprockets (~> 2.1.2) sprockets (~> 2.1.3)
activemodel (3.2.3) activemodel (3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
builder (~> 3.0.0) builder (~> 3.0.0)
activerecord (3.2.3) activerecord (3.2.6)
activemodel (= 3.2.3) activemodel (= 3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
arel (~> 3.0.2) arel (~> 3.0.2)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activeresource (3.2.3) activeresource (3.2.6)
activemodel (= 3.2.3) activemodel (= 3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
activesupport (3.2.3) activesupport (3.2.6)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
airbrake (3.0.9) airbrake (3.1.1)
activesupport activesupport
builder builder
albino (1.3.3) albino (1.3.3)
posix-spawn (>= 0.3.6) posix-spawn (>= 0.3.6)
ancestry (1.2.5) ancestry (1.3.0)
activerecord (>= 2.2.2) activerecord (>= 2.3.14)
arel (3.0.2) arel (3.0.2)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
blankslate (2.1.2.4) blankslate (2.1.2.4)
@ -87,13 +87,13 @@ GEM
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.3.1) coffee-script-source (1.3.3)
compass (0.12.1) compass (0.12.1)
chunky_png (~> 1.2) chunky_png (~> 1.2)
fssm (>= 0.2.7) fssm (>= 0.2.7)
sass (~> 3.1) sass (~> 3.1)
compass-rails (1.0.1) compass-rails (1.0.2)
compass (~> 0.12.0) compass (>= 0.12.0, < 0.14)
creole (0.4.2) creole (0.4.2)
daemons (1.1.6) daemons (1.1.6)
devise (2.0.4) devise (2.0.4)
@ -106,13 +106,13 @@ GEM
ejs (1.0.0) ejs (1.0.0)
erubis (2.7.0) erubis (2.7.0)
eventmachine (0.12.10) eventmachine (0.12.10)
execjs (1.3.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
expression_parser (0.9.0) expression_parser (0.9.0)
factory_girl (3.1.1) factory_girl (3.4.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (3.1.0) factory_girl_rails (3.4.0)
factory_girl (~> 3.1.0) factory_girl (~> 3.4.0)
railties (>= 3.0.0) railties (>= 3.0.0)
fssm (0.2.9) fssm (0.2.9)
github-markup (0.7.2) github-markup (0.7.2)
@ -125,14 +125,14 @@ GEM
redcarpet redcarpet
sanitize (~> 2.0.0) sanitize (~> 2.0.0)
sinatra (~> 1.0) sinatra (~> 1.0)
haml (3.1.4) haml (3.1.6)
haml-rails (0.3.4) haml-rails (0.3.4)
actionpack (~> 3.0) actionpack (~> 3.0)
activesupport (~> 3.0) activesupport (~> 3.0)
haml (~> 3.0) haml (~> 3.0)
railties (~> 3.0) railties (~> 3.0)
hashie (1.2.0) hashie (1.2.0)
highline (1.6.11) highline (1.6.12)
hike (1.2.1) hike (1.2.1)
hirb (0.6.2) hirb (0.6.2)
i18n (0.6.0) i18n (0.6.0)
@ -143,9 +143,11 @@ GEM
jquery-rails (2.0.2) jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0) railties (>= 3.2.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.6.6) json (1.7.3)
kgio (2.7.4) kgio (2.7.4)
libv8 (3.3.10.4) libv8 (3.3.10.4)
macaddr (1.6.1)
systemu (~> 2.5.0)
mail (2.4.4) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
@ -162,17 +164,17 @@ GEM
meta-tags (1.2.6) meta-tags (1.2.6)
actionpack actionpack
mime-types (1.18) mime-types (1.18)
multi_json (1.3.2) multi_json (1.3.6)
mustache (0.99.4) mustache (0.99.4)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
net-sftp (2.0.5) net-sftp (2.0.5)
net-ssh (>= 2.0.9) net-ssh (>= 2.0.9)
net-ssh (2.3.0) net-ssh (2.5.2)
net-ssh-gateway (1.1.0) net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
newrelic_rpm (3.3.4) newrelic_rpm (3.3.5)
nokogiri (1.5.2) nokogiri (1.5.4)
omniauth (1.0.3) omniauth (1.0.3)
hashie (~> 1.2) hashie (~> 1.2)
rack rack
@ -180,12 +182,16 @@ GEM
omniauth (~> 1.0) omniauth (~> 1.0)
rack-openid (~> 1.3.1) rack-openid (~> 1.3.1)
orm_adapter (0.0.7) orm_adapter (0.0.7)
paperclip (3.0.2) paperclip (3.0.4)
activemodel (>= 3.0.0) activemodel (>= 3.0.0)
activerecord (>= 3.0.0) activerecord (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
cocaine (>= 0.0.2) cocaine (>= 0.0.2)
mime-types mime-types
perform_later (1.3.0)
rails (~> 3.0)
redis
resque
pg (0.13.2) pg (0.13.2)
polyglot (0.3.3) polyglot (0.3.3)
posix-spawn (0.3.6) posix-spawn (0.3.6)
@ -201,14 +207,14 @@ GEM
rack rack
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rails (3.2.3) rails (3.2.6)
actionmailer (= 3.2.3) actionmailer (= 3.2.6)
actionpack (= 3.2.3) actionpack (= 3.2.6)
activerecord (= 3.2.3) activerecord (= 3.2.6)
activeresource (= 3.2.3) activeresource (= 3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.2.3) railties (= 3.2.6)
rails-backbone (0.7.2) rails-backbone (0.7.2)
coffee-script (~> 2.2.0) coffee-script (~> 2.2.0)
ejs (~> 1.0.0) ejs (~> 1.0.0)
@ -217,14 +223,14 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
rails3-jquery-autocomplete (1.0.7) rails3-jquery-autocomplete (1.0.7)
rails (~> 3.0) rails (~> 3.0)
railties (3.2.3) railties (3.2.6)
actionpack (= 3.2.3) actionpack (= 3.2.6)
activesupport (= 3.2.3) activesupport (= 3.2.6)
rack-ssl (~> 1.3.2) rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.6) thor (>= 0.14.6, < 2.0)
raindrops (0.8.0) raindrops (0.9.0)
rake (0.9.2.2) rake (0.9.2.2)
rdiscount (1.6.8) rdiscount (1.6.8)
rdoc (3.12) rdoc (3.12)
@ -233,36 +239,45 @@ GEM
redis (2.2.2) redis (2.2.2)
redis-namespace (1.0.3) redis-namespace (1.0.3)
redis (< 3.0.0) redis (< 3.0.0)
redisk (0.2.2)
redis (>= 0.1.1)
redis-namespace (>= 0.1.0)
resque (1.20.0) resque (1.20.0)
multi_json (~> 1.0) multi_json (~> 1.0)
redis-namespace (~> 1.0.2) redis-namespace (~> 1.0.2)
sinatra (>= 0.9.2) sinatra (>= 0.9.2)
vegas (~> 0.1.2) vegas (~> 0.1.2)
resque-status (0.3.3)
redisk (>= 0.2.1)
resque (~> 1.19)
uuid (~> 2.3)
resque_mailer (2.1.0)
actionmailer (~> 3.0)
rr (1.0.4) rr (1.0.4)
rspec (2.9.0) rspec (2.10.0)
rspec-core (~> 2.9.0) rspec-core (~> 2.10.0)
rspec-expectations (~> 2.9.0) rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.9.0) rspec-mocks (~> 2.10.0)
rspec-core (2.9.0) rspec-core (2.10.1)
rspec-expectations (2.9.1) rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3) diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0) rspec-mocks (2.10.1)
rspec-rails (2.9.0) rspec-rails (2.10.1)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec (~> 2.9.0) rspec (~> 2.10.0)
ruby-haml-js (0.0.3) ruby-haml-js (0.0.3)
execjs execjs
sprockets (>= 2.0.0) sprockets (>= 2.0.0)
ruby-openid (2.1.8) ruby-openid (2.1.8)
russian (0.6.0) russian (0.6.0)
i18n (>= 0.5.0) i18n (>= 0.5.0)
rvm-capistrano (1.1.0) rvm-capistrano (1.2.2)
capistrano (>= 2.0.0) capistrano (>= 2.0.0)
sanitize (2.0.3) sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6) nokogiri (>= 1.4.4, < 1.6)
sass (3.1.16) sass (3.1.19)
sass-rails (3.2.5) sass-rails (3.2.5)
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
@ -281,19 +296,20 @@ GEM
skinny (0.2.0) skinny (0.2.0)
eventmachine (~> 0.12) eventmachine (~> 0.12)
thin (~> 1.2) thin (~> 1.2)
sprockets (2.1.2) sprockets (2.1.3)
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6) sqlite3 (1.3.6)
state_machine (1.1.2) state_machine (1.1.2)
systemu (2.5.1)
therubyracer (0.10.1) therubyracer (0.10.1)
libv8 (~> 3.3.10) libv8 (~> 3.3.10)
thin (1.3.1) thin (1.3.1)
daemons (>= 1.0.9) daemons (>= 1.0.9)
eventmachine (>= 0.12.6) eventmachine (>= 0.12.6)
rack (>= 1.0.0) rack (>= 1.0.0)
thor (0.14.6) thor (0.15.2)
tilt (1.3.3) tilt (1.3.3)
treetop (1.4.10) treetop (1.4.10)
polyglot polyglot
@ -302,10 +318,12 @@ GEM
uglifier (1.2.4) uglifier (1.2.4)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (>= 1.0.2) multi_json (>= 1.0.2)
unicorn (4.2.1) unicorn (4.3.1)
kgio (~> 2.6) kgio (~> 2.6)
rack rack
raindrops (~> 0.7) raindrops (~> 0.7)
uuid (2.3.5)
macaddr (~> 1.0)
vegas (0.1.11) vegas (0.1.11)
rack (>= 1.0.0) rack (>= 1.0.0)
warden (1.1.1) warden (1.1.1)
@ -323,8 +341,8 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
RedCloth RedCloth
airbrake (~> 3.0.9) airbrake (~> 3.1.1)
ancestry (~> 1.2.5) ancestry (~> 1.3.0)
bluepill (~> 0.0.60) bluepill (~> 0.0.60)
cancan (~> 1.6.7) cancan (~> 1.6.7)
cape cape
@ -332,37 +350,39 @@ DEPENDENCIES
capistrano_colors capistrano_colors
charlock_holmes (~> 0.6.8) charlock_holmes (~> 0.6.8)
coffee-rails (~> 3.2.2) coffee-rails (~> 3.2.2)
compass-rails (~> 1.0.1) compass-rails (~> 1.0.2)
creole creole
daemons (= 1.1.6)
devise (~> 2.0.4) devise (~> 2.0.4)
diff-display (~> 0.0.1) diff-display (~> 0.0.1)
factory_girl_rails (~> 3.1.0) factory_girl_rails (~> 3.4.0)
gollum (= 1.3.1) gollum (= 1.3.1)
grack! grack!
grit! grit!
haml-rails (~> 0.3.4) haml-rails (~> 0.3.4)
highline (~> 1.6.11) highline (~> 1.6.11)
hirb hirb
jbuilder jbuilder (~> 0.4.0)
jquery-rails (~> 2.0.2) jquery-rails (~> 2.0.2)
mailcatcher mailcatcher
meta-tags (~> 1.2.5) meta-tags (~> 1.2.5)
newrelic_rpm (~> 3.3.3) newrelic_rpm (~> 3.3.5)
omniauth (~> 1.0.3) omniauth (~> 1.0.3)
omniauth-openid (~> 1.0.1) omniauth-openid (~> 1.0.1)
paperclip (~> 3.0.2) paperclip (~> 3.0.4)
perform_later (~> 1.3.0)
pg (~> 0.13.2) pg (~> 0.13.2)
rails (= 3.2.3) rails (= 3.2.6)
rails-backbone (~> 0.7.2) rails-backbone (~> 0.7.2)
rails3-generators rails3-generators
rails3-jquery-autocomplete (~> 1.0.7) rails3-jquery-autocomplete (~> 1.0.7)
rdiscount rdiscount
redcarpet (= 1.17.2) redcarpet (= 1.17.2)
redhillonrails_core! redhillonrails_core!
resque resque (~> 1.20.0)
resque-status (~> 0.3.3)
resque_mailer (~> 2.1.0)
rr (~> 1.0.4) rr (~> 1.0.4)
rspec-rails (~> 2.9.0) rspec-rails (~> 2.10.1)
ruby-haml-js (~> 0.0.3) ruby-haml-js (~> 0.0.3)
russian (~> 0.6.0) russian (~> 0.6.0)
rvm-capistrano rvm-capistrano
@ -373,7 +393,7 @@ DEPENDENCIES
therubyrhino (~> 1.73.1) therubyrhino (~> 1.73.1)
trinidad (~> 1.0.2) trinidad (~> 1.0.2)
uglifier (~> 1.2.4) uglifier (~> 1.2.4)
unicorn (~> 4.2.1) unicorn (~> 4.3.1)
whenever (~> 0.7.3) whenever (~> 0.7.3)
wikicloth wikicloth
will_paginate (~> 3.0.3) will_paginate (~> 3.0.3)

View File

@ -98,8 +98,7 @@ class Platforms::PlatformsController < Platforms::BaseController
end end
def destroy def destroy
@platform.async(:destroy) if @platform @platform.destroy
flash[:notice] = t("flash.platform.destroyed") flash[:notice] = t("flash.platform.destroyed")
redirect_to platforms_path redirect_to platforms_path
end end

View File

@ -132,7 +132,7 @@ class Projects::BuildListsController < Projects::BaseController
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@build_list.async(:publish) if @build_list.auto_publish # && @build_list.can_publish? @build_list.publish if @build_list.auto_publish # && @build_list.can_publish?
end end
def circle_build def circle_build
@ -197,7 +197,7 @@ class Projects::BuildListsController < Projects::BaseController
end end
end end
end end
if @build_list.save and @build_list.publish if @build_list.save and @build_list.now_publish
redirect_to :back, :notice => t('layout.build_lists.publish_success') redirect_to :back, :notice => t('layout.build_lists.publish_success')
else else
redirect_to :back, :notice => t('layout.build_lists.publish_fail') redirect_to :back, :notice => t('layout.build_lists.publish_fail')

View File

@ -255,10 +255,7 @@ class Projects::WikiController < Projects::BaseController
unless @committer unless @committer
p = commit_message.merge({:name => current_user.uname, :email => current_user.email}) p = commit_message.merge({:name => current_user.uname, :email => current_user.email})
@committer = Gollum::Committer.new(@wiki, p) @committer = Gollum::Committer.new(@wiki, p)
# @committer.after_commit do |committer, sha1| GitHook.perform_later!(:notifcations, :process, {:project_id => @project.id, :actor_name => @committer.actor.name, :commit_sha => @committer.commit})
# here goes callback for notification
# end
ActivityFeedObserver.instance.async(:after_create, @committer)
end end
@committer @committer
end end

View File

@ -3,9 +3,7 @@
class UserMailer < ActionMailer::Base class UserMailer < ActionMailer::Base
default :from => APP_CONFIG['do-not-reply-email'] default :from => APP_CONFIG['do-not-reply-email']
include Modules::Models::ResqueAsyncMethods include Resque::Mailer
@queue = :notifications
def new_user_notification(user) def new_user_notification(user)
@user = user @user = user

View File

@ -2,10 +2,6 @@
class ActivityFeedObserver < ActiveRecord::Observer class ActivityFeedObserver < ActiveRecord::Observer
observe :issue, :comment, :user, :build_list observe :issue, :comment, :user, :build_list
include Modules::Models::ResqueAsyncMethods
@queue = :notifications
def after_create(record) def after_create(record)
case record.class.to_s case record.class.to_s
when 'User' when 'User'
@ -19,7 +15,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
recipients = record.collect_recipient_ids recipients = record.collect_recipient_ids
recipients.each do |recipient_id| recipients.each do |recipient_id|
recipient = User.find(recipient_id) recipient = User.find(recipient_id)
UserMailer.async(:new_issue_notification, record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue UserMailer.new_issue_notification(record, recipient).deliver if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue
ActivityFeed.create( ActivityFeed.create(
:user => recipient, :user => recipient,
:kind => 'new_issue_notification', :kind => 'new_issue_notification',
@ -29,7 +25,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
end end
if record.assignee_id_changed? if record.assignee_id_changed?
UserMailer.async(:new_issue_notification, record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify UserMailer.new_issue_notification(record, record.assignee).deliver if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
ActivityFeed.create( ActivityFeed.create(
:user => record.user, :user => record.user,
:kind => 'issue_assign_notification', :kind => 'issue_assign_notification',
@ -43,7 +39,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
subscribes = record.commentable.subscribes subscribes = record.commentable.subscribes
subscribes.each do |subscribe| subscribes.each do |subscribe|
if record.user_id != subscribe.user_id if record.user_id != subscribe.user_id
UserMailer.async(:new_comment_notification, record, subscribe.user) if record.can_notify_on_new_comment?(subscribe) UserMailer.new_comment_notification(record, subscribe.user).deliver if record.can_notify_on_new_comment?(subscribe)
ActivityFeed.create( ActivityFeed.create(
:user => subscribe.user, :user => subscribe.user,
:kind => 'new_comment_notification', :kind => 'new_comment_notification',
@ -61,7 +57,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
( (subscribe.project.owner?(subscribe.user) && subscribe.user.notifier.new_comment_commit_repo_owner) or ( (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.commentor?(record.commentable) && subscribe.user.notifier.new_comment_commit_commentor) or
(subscribe.user.committer?(record.commentable) && subscribe.user.notifier.new_comment_commit_owner) ) (subscribe.user.committer?(record.commentable) && subscribe.user.notifier.new_comment_commit_owner) )
UserMailer.async(:new_comment_notification, record, subscribe.user) UserMailer.new_comment_notification(record, subscribe.user).deliver
end end
ActivityFeed.create( ActivityFeed.create(
:user => subscribe.user, :user => subscribe.user,
@ -97,26 +93,23 @@ class ActivityFeedObserver < ActiveRecord::Observer
end end
record.project.owner_and_admin_ids.each do |recipient| record.project.owner_and_admin_ids.each do |recipient|
ActivityFeed.create( ActivityFeed.create!(
:user => User.find(recipient), :user => User.find(recipient),
:kind => kind, :kind => kind,
:data => options :data => options
) )
end end
when 'Gollum::Committer' when 'Hash' # 'Gollum::Committer'
actor = User.find_by_uname(record.actor.name) actor = User.find_by_uname! record[:actor_name]
project_name = record.wiki.path.match(/\/(\w+)\.wiki\.git$/)[1] project = Project.find record[:project_id]
project = Project.find_by_name(project_name)
commit_sha = record.commit
#wiki_name = record.wiki.name
project.owner_and_admin_ids.each do |recipient| project.owner_and_admin_ids.each do |recipient|
ActivityFeed.create( ActivityFeed.create!(
:user => User.find(recipient),#record.user, :user => User.find(recipient),#record.user,
:kind => 'wiki_new_commit_notification', :kind => 'wiki_new_commit_notification',
:data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id, :data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id,
:project_name => project_name, :commit_sha => commit_sha, :project_owner => project.owner.uname} :project_name => project.name, :commit_sha => record[:commit_sha], :project_owner => project.owner.uname}
) )
end end
end end
@ -126,7 +119,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
case record.class.to_s case record.class.to_s
when 'Issue' when 'Issue'
if record.assignee_id && record.assignee_id_changed? if record.assignee_id && record.assignee_id_changed?
UserMailer.async(:issue_assign_notification, record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify UserMailer.issue_assign_notification(record, record.assignee).deliver if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
ActivityFeed.create( ActivityFeed.create(
:user => record.assignee, :user => record.assignee,
:kind => 'issue_assign_notification', :kind => 'issue_assign_notification',

View File

@ -136,6 +136,7 @@ class BuildList < ActiveRecord::Base
update_attribute(:status, has_published == 0 ? BUILD_PUBLISH : FAILED_PUBLISH) update_attribute(:status, has_published == 0 ? BUILD_PUBLISH : FAILED_PUBLISH)
return has_published == 0 return has_published == 0
end end
later :publish, :loner => true, :queue => :clone_and_build
def can_publish? def can_publish?
status == BuildServer::SUCCESS or status == FAILED_PUBLISH status == BuildServer::SUCCESS or status == FAILED_PUBLISH

View File

@ -3,10 +3,12 @@ class GitHook
attr_reader :repo, :newrev, :oldrev, :newrev_type, :oldrev_type, :refname, attr_reader :repo, :newrev, :oldrev, :newrev_type, :oldrev_type, :refname,
:change_type, :rev, :rev_type, :refname_type, :owner, :project :change_type, :rev, :rev_type, :refname_type, :owner, :project
include Resque::Plugins::Status
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type) def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
@repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type @repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first!
@project = @owner.projects.where(:name => repo).first @project = @owner.own_projects.where(:name => repo).first!
end end
@change_type = git_change_type @change_type = git_change_type
git_revision_types git_revision_types
@ -55,4 +57,8 @@ class GitHook
@refname_type= "*** Unknown type of update to $refname (#{rev_type})" @refname_type= "*** Unknown type of update to $refname (#{rev_type})"
end end
end end
def self.process(*args)
ActivityFeedObserver.instance.after_create(args.size > 1 ? GitHook.new(*args) : args.first)
end
end end

View File

@ -12,10 +12,6 @@ class MassBuild < ActiveRecord::Base
after_create :build_all after_create :build_all
include Modules::Models::ResqueAsyncMethods
@queue = :clone_and_build
def initialize(args = nil) def initialize(args = nil)
super super
@ -28,7 +24,7 @@ class MassBuild < ActiveRecord::Base
# ATTENTION: repositories and arches must be set before calling this method! # ATTENTION: repositories and arches must be set before calling this method!
def build_all def build_all
platform.async(:build_all, platform.build_all(
:mass_build_id => self.id, :mass_build_id => self.id,
:user => self.user, :user => self.user,
:repositories => self.repositories, :repositories => self.repositories,

View File

@ -47,9 +47,6 @@ class Platform < ActiveRecord::Base
attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type
include Modules::Models::Owner include Modules::Models::Owner
include Modules::Models::ResqueAsyncMethods
@queue = :clone_and_build
def urpmi_list(host, pair = nil) def urpmi_list(host, pair = nil)
blank_pair = {:login => 'login', :pass => 'password'} blank_pair = {:login => 'login', :pass => 'password'}
@ -121,7 +118,7 @@ class Platform < ActiveRecord::Base
def full_clone(attrs = {}) def full_clone(attrs = {})
base_clone(attrs).tap do |c| base_clone(attrs).tap do |c|
with_skip {c.save} and c.clone_relations(self) and c.async(:xml_rpc_clone) with_skip {c.save} and c.clone_relations(self) and c.xml_rpc_clone
end end
end end
@ -175,17 +172,19 @@ class Platform < ActiveRecord::Base
begin begin
p.build_for(self, user, arch, auto_publish, mass_build_id) p.build_for(self, user, arch, auto_publish, mass_build_id)
rescue RuntimeError, Exception rescue RuntimeError, Exception
p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
end end
end end
end end
end end
end end
end end
later :build_all, :loner => true, :queue => :clone_and_build
def destroy def destroy
with_skip {super} # avoid cascade XML RPC requests with_skip {super} # avoid cascade XML RPC requests
end end
later :destroy, :loner => true, :queue => :clone_and_build
protected protected
@ -219,6 +218,7 @@ class Platform < ActiveRecord::Base
raise "Failed to clone platform #{old_name} with code #{result}. Path: #{build_path(old_name)} to platform #{new_name}" raise "Failed to clone platform #{old_name} with code #{result}. Path: #{build_path(old_name)} to platform #{new_name}"
end end
end end
later :xml_rpc_clone, :loner => true, :queue => :clone_and_build
def freeze_platform def freeze_platform
if released_changed? && released == true if released_changed? && released == true

View File

@ -41,12 +41,12 @@ class Project < ActiveRecord::Base
after_create :attach_to_personal_repository after_create :attach_to_personal_repository
after_create :create_git_repo after_create :create_git_repo
after_create {|p| p.async(:fork_git_repo) unless is_root?} after_create {|p| p.fork_git_repo unless is_root?}
after_save :create_wiki after_save :create_wiki
after_destroy :destroy_git_repo after_destroy :destroy_git_repo
after_destroy :destroy_wiki after_destroy :destroy_wiki
after_save {|p| p.async(:import_attached_srpm) if p.srpm?} # should be after create_git_repo after_save {|p| p.import_attached_srpm if p.srpm?} # should be after create_git_repo
# after_rollback lambda { destroy_git_repo rescue true if new_record? } # after_rollback lambda { destroy_git_repo rescue true if new_record? }
has_ancestry has_ancestry
@ -54,9 +54,6 @@ class Project < ActiveRecord::Base
has_attached_file :srpm has_attached_file :srpm
include Modules::Models::Owner include Modules::Models::Owner
include Modules::Models::ResqueAsyncMethods
@queue = :fork_import_hook
def to_param def to_param
name name
@ -222,11 +219,6 @@ class Project < ActiveRecord::Base
owner == user owner == user
end end
def self.process_hook(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
rec = GitHook.new(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
ActivityFeedObserver.instance.after_create rec
end
def owner_and_admin_ids def owner_and_admin_ids
recipients = self.relations.by_role('admin').where(:actor_type => 'User').map { |rel| rel.read_attribute(:actor_id) } recipients = self.relations.by_role('admin').where(:actor_type => 'User').map { |rel| rel.read_attribute(:actor_id) }
recipients = recipients | [self.owner_id] if self.owner_type == 'User' recipients = recipients | [self.owner_id] if self.owner_type == 'User'
@ -255,14 +247,15 @@ class Project < ActiveRecord::Base
def create_git_repo def create_git_repo
if is_root? if is_root?
Grit::Repo.init_bare(path) Grit::Repo.init_bare(path)
async(:write_hook) write_hook
end end
end end
def fork_git_repo def fork_git_repo
dummy = Grit::Repo.new(path) rescue parent.git_repository.repo.fork_bare(path) dummy = Grit::Repo.new(path) rescue parent.git_repository.repo.fork_bare(path)
write_hook now_write_hook
end end
later :fork_git_repo, :loner => true, :queue => :fork_import_hook
def destroy_git_repo def destroy_git_repo
FileUtils.rm_rf path FileUtils.rm_rf path
@ -274,7 +267,7 @@ class Project < ActiveRecord::Base
self.srpm = nil; save # clear srpm self.srpm = nil; save # clear srpm
end end
end end
later :import_attached_srpm, :loner => true, :queue => :fork_import_hook
def create_wiki def create_wiki
if has_wiki && !FileTest.exist?(wiki_path) if has_wiki && !FileTest.exist?(wiki_path)
@ -294,7 +287,7 @@ class Project < ActiveRecord::Base
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") 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) FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
File.open(hook, 'a') do |f| 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.async(: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 rake hook:enqueue[$owner,$reponame,$newrev,$oldrev,$ref,$newrev_type,$oldrev_type]\""
s << " > /dev/null 2>&1" if is_production s << " > /dev/null 2>&1" if is_production
s << "\ndone\n" s << "\ndone\n"
f.write(s) f.write(s)
@ -307,4 +300,5 @@ class Project < ActiveRecord::Base
rescue Exception # FIXME rescue Exception # FIXME
end end
later :write_hook, :loner => true, :queue => :fork_import_hook
end end

View File

@ -16,10 +16,6 @@ class Repository < ActiveRecord::Base
attr_accessible :name, :description attr_accessible :name, :description
attr_readonly :name, :platform_id attr_readonly :name, :platform_id
include Modules::Models::ResqueAsyncMethods
@queue = :clone_and_build
def base_clone(attrs = {}) def base_clone(attrs = {})
dup.tap do |c| dup.tap do |c|
c.platform_id = nil c.platform_id = nil
@ -33,10 +29,11 @@ class Repository < ActiveRecord::Base
from.projects.find_each {|p| self.projects << p} from.projects.find_each {|p| self.projects << p}
end end
end end
later :clone_relations, :loner => true, :queue => :clone_and_build
def full_clone(attrs = {}) def full_clone(attrs = {})
base_clone(attrs).tap do |c| base_clone(attrs).tap do |c|
with_skip {c.save} and c.async(:clone_relations, self) with_skip {c.save} and c.clone_relations(self)
end end
end end

View File

@ -36,9 +36,7 @@ set :deploy_via, :remote_cache
require './lib/recipes/nginx' require './lib/recipes/nginx'
require './lib/recipes/unicorn' require './lib/recipes/unicorn'
#require './lib/recipes/bluepill' #require './lib/recipes/bluepill'
set :workers_count, 4 set :workers_count, 4
require './lib/recipes/resque' require './lib/recipes/resque'
namespace :deploy do namespace :deploy do

View File

@ -0,0 +1,13 @@
require 'resque/server'
require 'resque/status_server'
::ResqueServer = ::Resque::Server # need for CanCan
Resque::Mailer.default_queue_name = 'notifications'
Resque::Mailer.excluded_environments = [:test]
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

View File

@ -12,6 +12,3 @@ Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack:
Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth
Rosa::Application.config.action_mailer.default_url_options = { :host => APP_CONFIG['action_mailer_host'] } if APP_CONFIG['action_mailer_host'] Rosa::Application.config.action_mailer.default_url_options = { :host => APP_CONFIG['action_mailer_host'] } if APP_CONFIG['action_mailer_host']
require 'resque/server'
::ResqueServer = ::Resque::Server # need for CanCan

View File

@ -8,7 +8,7 @@ Bluepill.application(app_name, :log_file => "/srv/rosa_build/shared/log/bluepill
app.process("resque") do |process| app.process("resque") do |process|
process.group = "resque" process.group = "resque"
pid_path = File.join(app.working_dir, 'tmp', 'pids', 'resque.pid') pid_path = File.join(app.working_dir, 'tmp', 'pids', 'resque.pid')
process.start_command = "bundle exec rake resque:work QUEUE=fork_and_import PIDFILE=#{ pid_path } BACKGROUND=yes" process.start_command = "bundle exec rake resque:work QUEUE=fork_import_hook PIDFILE=#{ pid_path } BACKGROUND=yes"
process.pid_file = pid_path process.pid_file = pid_path
process.stop_command = "kill -QUIT {{PID}}" process.stop_command = "kill -QUIT {{PID}}"
process.daemonize = true process.daemonize = true

View File

@ -0,0 +1,22 @@
class DropDelayedJobs < ActiveRecord::Migration
def up
drop_table :delayed_jobs
end
def down
create_table :delayed_jobs do |t|
t.integer "priority", :default => 0
t.integer "attempts", :default => 0
t.text "handler"
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.datetime "created_at"
t.datetime "updated_at"
t.string "queue", :default => "default"
end
add_index :delayed_jobs, ["priority", "run_at"], :name => "delayed_jobs_priority"
end
end

View File

@ -11,14 +11,14 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120529130537) do ActiveRecord::Schema.define(:version => 20120609163454) do
create_table "activity_feeds", :force => true do |t| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
t.string "kind" t.string "kind"
t.text "data" t.text "data"
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
end end
create_table "advisories", :force => true do |t| create_table "advisories", :force => true do |t|
@ -136,22 +136,6 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
t.integer "project_id" t.integer "project_id"
end end
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
t.integer "attempts", :default => 0
t.text "handler"
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.datetime "created_at"
t.datetime "updated_at"
t.string "queue", :default => "default"
end
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "event_logs", :force => true do |t| create_table "event_logs", :force => true do |t|
t.integer "user_id" t.integer "user_id"
t.string "user_name" t.string "user_name"
@ -304,25 +288,27 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
t.text "description" t.text "description"
t.string "ancestry" t.string "ancestry"
t.boolean "has_issues", :default => true t.boolean "has_issues", :default => true
t.boolean "has_wiki", :default => false
t.string "srpm_file_name" t.string "srpm_file_name"
t.string "srpm_content_type" t.string "srpm_content_type"
t.integer "srpm_file_size" t.integer "srpm_file_size"
t.datetime "srpm_updated_at" t.datetime "srpm_updated_at"
t.boolean "has_wiki", :default => false
t.string "default_branch", :default => "master" t.string "default_branch", :default => "master"
t.boolean "is_package", :default => true, :null => false t.boolean "is_package", :default => true, :null => false
t.integer "average_build_time", :default => 0, :null => false t.integer "average_build_time", :default => 0, :null => false
t.integer "build_count", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false
end end
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
create_table "register_requests", :force => true do |t| create_table "register_requests", :force => true do |t|
t.string "name" t.string "name"
t.string "email" t.string "email"
t.string "token" t.string "token"
t.boolean "approved", :default => false t.boolean "approved", :default => false
t.boolean "rejected", :default => false t.boolean "rejected", :default => false
t.datetime "created_at", :null => false t.datetime "created_at"
t.datetime "updated_at", :null => false t.datetime "updated_at"
t.string "interest" t.string "interest"
t.text "more" t.text "more"
end end
@ -376,7 +362,6 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
t.string "name" t.string "name"
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "reset_password_token" t.string "reset_password_token"
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.datetime "created_at" t.datetime "created_at"
@ -384,11 +369,8 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
t.string "uname" t.string "uname"
t.string "role" t.string "role"
t.string "language", :default => "en" t.string "language", :default => "en"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.datetime "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.text "professional_experience" t.text "professional_experience"
t.string "site" t.string "site"
t.string "company" t.string "company"
@ -400,6 +382,9 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
t.integer "failed_attempts", :default => 0 t.integer "failed_attempts", :default => 0
t.string "unlock_token" t.string "unlock_token"
t.datetime "locked_at" t.datetime "locked_at"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "authentication_token" t.string "authentication_token"
t.integer "build_priority", :default => 50 t.integer "build_priority", :default => 50
end end

View File

@ -1,32 +0,0 @@
# -*- 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

View File

@ -6,7 +6,7 @@ namespace :hook do
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook") 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) FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
File.open(hook, 'a') do |f| 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.async(: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 rake hook:enqueue[$owner,$reponame,$newrev,$oldrev,$ref,$newrev_type,$oldrev_type]\""
s << " > /dev/null 2>&1" if is_production s << " > /dev/null 2>&1" if is_production
s << "\ndone\n" s << "\ndone\n"
f.write(s) f.write(s)
@ -32,6 +32,14 @@ namespace :hook do
FileUtils.rm_rf(hook) FileUtils.rm_rf(hook)
end end
desc 'Enqueue hook process'
task :enqueue, :owner, :reponame, :newrev, :oldrev, :ref, :newrev_type, :oldrev_type do |t, args|
# require 'resque'
require './app/models/git_hook'
PerformLater.config.enabled = true unless Rails.env.test?
GitHook.perform_later!(:fork_import_hook, :process, *args.to_hash.values)
end
desc "remove git hook from all repos" desc "remove git hook from all repos"
task :remove => :environment do task :remove => :environment do
say "process.." say "process.."

View File

@ -1,6 +0,0 @@
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= "production"
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize

View File

@ -43,7 +43,7 @@ def test_git_commit(project)
project.git_repository.repo.index.commit('Test commit') project.git_repository.repo.index.commit('Test commit')
end end
Delayed::Worker.delay_jobs = false # Execute all jobs realtime Resque.inline = true
# Add testing root_path # Add testing root_path
%x(rm -Rf #{Rails.root}/tmp/test_root) %x(rm -Rf #{Rails.root}/tmp/test_root)