Module: CapistranoDeployManagement::Rails

Defined in:
lib/capistrano-deploy-management/rails.rb

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



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
# File 'lib/capistrano-deploy-management/rails.rb', line 3

def self.load_into(configuration)
  configuration.load do
    set :rake do
      if using_recipe?(:bundle)
        'bundle exec rake'
      else
        'rake'
      end
    end

    set(:rails_env) { 'production' }

    namespace :deploy do
      desc 'Deploy & migrate'
      task :migrations do
        update
        migrate
        restart
      end

      desc 'Run migrations'
      task :migrate, :roles => :db, :only => {:primary => true} do
        run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} db:migrate"
      end
    end

    namespace :log do
      # TODO: add argument to specify arbitrary log files; default is environment log
      desc 'Show remote log file'
      task :show do
        run "tail -n 100 -f #{current_path}/log/#{rails_env}.log"
      end
    end

  end
end