Sha256: f71b35454323a11cd0829ffccd37e4c9a5bef35e97b8f18c3e76eeb9af89bb19

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 Bytes

Contents

@@cap_config.load do
  namespace :log do
    
    desc "Tail application log file for the specified environment, e.g. cap staging log:tail"
    task :tail, :roles => :app do
      run "tail -f #{shared_path}/log/#{stage}.log" do |channel, stream, data|
        puts "#{channel[:host]}: #{data}"
        break if stream == :err
      end
    end
    
    desc <<-DESC
    Install log rotation script; optional args: days=7, size=5M, group (defaults to same value as :user)
    DESC
    task :rotate, :roles => :app do
      rotate_script = %Q{#{shared_path}/log/#{stage}.log {
        daily
        rotate #{ENV['days'] || 7}
        size #{ENV['size'] || "5M"}
        compress
        create 640 #{user} #{ENV['group'] || user}
        missingok
      }}
      put rotate_script, "#{shared_path}/logrotate_script"
      "#{sudo} cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"
      run "rm #{shared_path}/logrotate_script"
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
webficient-capistrano-recipes-0.2.0 lib/recipes/log.rb
webficient-capistrano-recipes-0.3.0 lib/recipes/log.rb
capistrano-recipes-0.4.0 lib/recipes/log.rb