Skip to content

Instantly share code, notes, and snippets.

@duksis
Created February 15, 2012 21:26
Show Gist options
  • Save duksis/1839098 to your computer and use it in GitHub Desktop.
Save duksis/1839098 to your computer and use it in GitHub Desktop.
Capistrano receipt configure logrotate
namespace :deploy do
desc "Configure logrotate"
task :logrotate, :roles => :install do
config_file = "/etc/logrotate.d/app_#{rails_env}"
config_lines = ["daily",
"rotate 10",
"missingok",
"nocompress",
"sharedscripts",
"postrotate",
" touch #{current_path}/tmp/restart.txt",
"endscript"
]
command_string = "echo '#{shared_path}/log/*.log {' > #{config_file}" if config_lines
config_lines.each { |line|
command_string << "; echo '#{line}' >> #{config_file}"
}
command_string << "; echo '}' >> #{config_file}" if config_lines
sudo "sh -c \"#{command_string}\"", :pty => true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment