Permalink
Browse files

Now running airbrake deploy notifications on the REMOTE machine.

  • Loading branch information...
1 parent 582dce9 commit f12aa5355292a3ac8efbba2673c800e5aff067b3 Jonathan Siegel committed Nov 1, 2011
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/airbrake/capistrano.rb
View
@@ -9,17 +9,25 @@ def self.load_into(configuration)
after "deploy:migrations", "airbrake:deploy"
namespace :airbrake do
- desc "Notify Airbrake of the deployment"
+ desc <<-DESC
+ Notify Airbrake of the deployment by running the notification on the REMOTE machine.
+ - Run remotely so we use remote API keys, environment, etc.
+ DESC
task :deploy, :except => { :no_release => true } do
rails_env = fetch(:airbrake_env, fetch(:rails_env, "production"))
local_user = ENV['USER'] || ENV['USERNAME']
executable = RUBY_PLATFORM.downcase.include?('mswin') ? fetch(:rake, 'rake.bat') : fetch(:rake, 'rake')
- notify_command = "#{executable} airbrake:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
+ directory = current_release
+ notify_command = "cd #{directory}; #{executable} RAILS_ENV=#{rails_env} airbrake:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
notify_command << " DRY_RUN=true" if dry_run
notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
logger.info "Notifying Airbrake of Deploy (#{notify_command})"
- `#{notify_command}` if !configuration.dry_run
- logger.info "Airbrake Notification Complete."
+ if configuration.dry_run
+ logger.info "DRY RUN: Notification not actually run."
+ else
+ run(notify_command)
+ logger.info "Airbrake Notification Complete."
+ end
end
end
end

0 comments on commit f12aa53

Please sign in to comment.