Module: CapistranoDeployManagement::Whenever

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

def self.load_into(configuration)
  configuration.load do

    set :whenever_cmd do
      if using_recipe?(:bundle)
        'bundle exec whenever'
      else
        'whenever'
      end
    end

    set :whenever_identifier do
      if using_recipe?(:multistage)
        "#{application}_#{current_stage}"
      else
        application
      end
    end

    namespace :whenever do
      desc 'Update crontab file'
      task :update_crontab, :roles => :db, :only => {:primary => true} do
        run "cd #{current_path} && #{whenever_cmd} --update-crontab #{whenever_identifier}"
      end

      desc 'Clear crontab file'
      task :clear_crontab, :roles => :db, :only => {:primary => true} do
        run "cd #{current_path} && #{whenever_cmd} --clear-crontab #{whenever_identifier}"
      end
    end

    after 'deploy:restart', 'whenever:update_crontab'

  end
end