From 0ff9698b4911d34c3be2c649683bf30651031a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Tue, 20 Sep 2011 16:03:42 +0100 Subject: [PATCH 1/8] Rescue rcov tasks if Cucumber or Rspec are unavailable (e.g. production) This is probably a better general solution than checking if we're on Heroku Conflicts: lib/tasks/rcov.rake --- lib/tasks/rcov.rake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tasks/rcov.rake b/lib/tasks/rcov.rake index a54f438059..d4f2d2dc3e 100644 --- a/lib/tasks/rcov.rake +++ b/lib/tasks/rcov.rake @@ -1,4 +1,4 @@ -unless Teambox.config.heroku? +begin require 'cucumber/rake/task' require 'rspec/core/rake_task' @@ -23,4 +23,10 @@ unless Teambox.config.heroku? Rake::Task["rcov:rspec_run"].invoke end end + +rescue LoadError + desc 'RCov rake tasks not available (Cucumber or RSpec not installed)' + task :rcov do + abort 'RCov tasks are not available. Make sure Cucumber and RSpec are installed.' + end end \ No newline at end of file From 0c2b081cf38fe37d48eb43d0b15a4517ddf21225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 11:49:08 +0100 Subject: [PATCH 2/8] Ensure receive_email script PWD is the application root to fix relative paths Some paths in the application are interpreted as relative to the present working directory. If the user does not first cd to the Rails root, this causes the application to bomb out at various places when running receive_mail. --- script/receive_email | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/script/receive_email b/script/receive_email index 7565067754..9bd282ecae 100755 --- a/script/receive_email +++ b/script/receive_email @@ -1,15 +1,19 @@ #!/usr/bin/env ruby # This script can be used to process an incoming e-mail, e.g. by configuring Postfix to pipe it here -ENV['RAILS_ENV'] = ENV['RAILS_ENV'] || 'production' -log_file = File.dirname(__FILE__) + '/../log/' + ENV['RAILS_ENV'] + '.log' +Dir.chdir File.join(File.dirname(__FILE__), '..') do -# Send output to the log so we don't generate a bounce message -$stderr.reopen(log_file, 'a') -$stderr.sync = true -$stdout.reopen(log_file, 'a') -$stderr.sync = true + ENV['RAILS_ENV'] = ENV['RAILS_ENV'] || 'production' + log_file = File.dirname(__FILE__) + '/../log/' + ENV['RAILS_ENV'] + '.log' -require File.dirname(__FILE__) + '/../config/environment' + # Send output to the log so we don't generate a bounce message + $stderr.reopen(log_file, 'a') + $stderr.sync = true + $stdout.reopen(log_file, 'a') + $stderr.sync = true -Emailer.receive(STDIN.read) \ No newline at end of file + require File.dirname(__FILE__) + '/../config/environment' + + Emailer.receive(STDIN.read) + +end \ No newline at end of file From 4524be994723bd4f47c0e9f4e9abb0a304940048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 12:49:02 +0100 Subject: [PATCH 3/8] Whenever 0.7 should be required, for its Bundler support Conflicts: Gemfile.lock --- Gemfile | 2 +- Gemfile.lock | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 4f18360433..acc24f8fb8 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'activesupport-i18n-patch', :git => 'git://github.com/teambox/activesupport- gem 'nokogiri' gem 'SystemTimer', '~> 1.2.0', :require => 'system_timer' -gem 'whenever', '~> 0.4.1', :require => nil +gem 'whenever', '~> 0.7.0', :require => nil gem 'icalendar', '~> 1.1.3' gem 'libxml-ruby', '1.1.3', :require => 'libxml' gem 'rdiscount', '~> 1.6.3' diff --git a/Gemfile.lock b/Gemfile.lock index 7435032e02..f74f0e339d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,7 @@ GEM cgi_multipart_eof_fix (2.5.0) childprocess (0.2.2) ffi (~> 1.0.6) - chronic (0.5.0) + chronic (0.6.4) cocaine (0.1.0) columnize (0.3.4) configuration (1.3.1) @@ -283,8 +283,9 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) - whenever (0.4.2) - chronic (>= 0.2.3) + whenever (0.7.0) + activesupport (>= 2.3.4) + chronic (~> 0.6.3) xml-simple (1.1.0) xpath (0.1.4) nokogiri (~> 1.3) @@ -350,5 +351,5 @@ DEPENDENCIES unicorn vestal_versions (~> 1.2.2)! webrat - whenever (~> 0.4.1) + whenever (~> 0.7.0) will_paginate! From 36ce5aa4995d62f5d6ce3de9a9adc9a338611e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 13:15:03 +0100 Subject: [PATCH 4/8] Fix Whenever config by loading Rails See https://github.com/javan/whenever/issues/144 --- config/schedule.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/schedule.rb b/config/schedule.rb index 799b2b4cb8..baf683d7b2 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,4 +1,9 @@ -set :output, "#{Rails.root}/log/cron.log" +# When running Whenever, the environment should be specified with --set environment +ENV['RAILS_ENV'] = environment || 'production' + +require File.join(File.dirname(__FILE__), "environment") + +set :output, File.join(Rails.root, "log", "cron.log") every 1.hour do rake "mail:reminders", :environment => :production From beb229c99f9254385533b679ad7a552418d16421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 13:46:57 +0100 Subject: [PATCH 5/8] Don't set up a cron job for receiving mail if we're piping it --- config/schedule.rb | 6 ++++-- config/teambox.yml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index baf683d7b2..71a9a157f8 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -9,8 +9,10 @@ rake "mail:reminders", :environment => :production end -every 1.minutes do - rake "mail:inbox", :environment => :production +if Teambox.config.allow_incoming_email and Teambox.config.incoming_email_settings[:type].downcase != 'pipe' + every 1.minutes do + rake "mail:inbox", :environment => :production + end end every 15.minutes do diff --git a/config/teambox.yml b/config/teambox.yml index 184a999a85..7799323679 100644 --- a/config/teambox.yml +++ b/config/teambox.yml @@ -85,6 +85,7 @@ defaults: &defaults # * Run `rake mail:inbox` periodically from cron to process incoming emails. # Important: Email should be received in the same domain it's being sent from. incoming_email_settings: + # Set this to "pipe" if piping the mail directly to the receive_mail script :type: POP :address: mail.example.com :user_name: USER From 090baa9aaca7f2e8a6ecad9cabc1e724c1a84330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 14:36:01 +0100 Subject: [PATCH 6/8] The Sphinx cron job should only reindex, not rebuild Rebuilding is only necessary when the schema changes, so doing this is a job for the deployment script Conflicts: config/schedule.rb --- config/schedule.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index 71a9a157f8..5f3083ce94 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -20,5 +20,5 @@ end every 30.minutes do - rake "ts:rebuild", :environment => :production -end + rake "ts:reindex", :environment => :production +end \ No newline at end of file From 0ed81954dfeac1f7b85fc0eacb6bd065a747e3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 21 Sep 2011 19:25:01 +0100 Subject: [PATCH 7/8] Fix GenerateUploadTokensIfMissing migration breakage for deleted comments --- app/models/upload.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/upload.rb b/app/models/upload.rb index bdc472f0ff..920795e382 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -225,7 +225,7 @@ def copy_ownership_from_comment end def inherit_privacy # before_save - if comment_id + if comment_id and comment self.is_private = comment.is_private end true From 6d3912568364771c0aad945a20e3b3dd790ce738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Wed, 16 Nov 2011 14:05:45 +0000 Subject: [PATCH 8/8] Fix output redirection in receive_email script --- script/receive_email | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/receive_email b/script/receive_email index 9bd282ecae..65e2bb6893 100755 --- a/script/receive_email +++ b/script/receive_email @@ -10,7 +10,7 @@ Dir.chdir File.join(File.dirname(__FILE__), '..') do $stderr.reopen(log_file, 'a') $stderr.sync = true $stdout.reopen(log_file, 'a') - $stderr.sync = true + $stdout.sync = true require File.dirname(__FILE__) + '/../config/environment'