Rakefile 1.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
require 'vlad'
require 'renfield'
require 'bundler/vlad'

Vlad.load :app => :passenger,
          :scm => :git

Dir.glob(File.dirname(__FILE__) + '/lib/*') {|file| require file}

def prepare(stage)
  info "Pointing to #{stage[:name]}"
  set :domain,        stage[:domain]
  set :application,   stage[:application]
  set :deploy_to,     stage[:deploy_to]
  set :rails_env,     stage[:rails_env]
  set :repository,    stage[:repository]
  set :revision,      stage[:revision]
  set :ssh_flags,     stage[:ssh_flags] || '-p 30262'
  set :shared_paths,  stage[:shared_paths] if stage[:shared_paths]
  set :mkdirs,        stage[:mkdirs] if stage[:mkdirs]
  set :app,           stage[:app] if stage[:app]
  set :web_command,   stage[:web_command] if stage[:web_command]
end

@dump_releases=nil
def dump_releases
  if @dump_releases.nil?
    @dump_releases=run("ls -x #{dumps_path}").split.sort
  end
  return @dump_releases
end

def dumps_path
  return File.join(shared_path, 'dumps')
end

@dump_path=nil
def dump_path
  if @dump_path.nil?
    @dump_path = File.join(dumps_path, now)
    run "mkdir -p #{@dump_path}"
  end
  return @dump_path
end

namespace :vlad do
  desc "Notify deploy"
  remote_task :notify_deploy do
    info "Notifying to errbit"
    run "cd #{current_path} && bundle exec rake airbrake:deploy RAILS_ENV=#{rails_env} TO=#{rails_env} REVISION='#{revision.split('/').last}' USER=`whoami` REPO=#{repository}"
  end

  desc "Notify deploy without bundler"
  remote_task :notify_deploy_without_bundler do
    info "Notifying to errbit"
    run "cd #{current_path} && rake airbrake:deploy RAILS_ENV=#{rails_env} TO=#{rails_env} REVISION='#{revision.split('/').last}' USER=`whoami` REPO=#{repository}"
  end
end