Created
February 15, 2012 21:26
-
-
Save duksis/1839098 to your computer and use it in GitHub Desktop.
Capistrano receipt configure logrotate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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