Created
January 10, 2012 21:55
-
-
Save johnantoni/1591435 to your computer and use it in GitHub Desktop.
Install log rotate script for Capistrano
This file contains hidden or 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
| desc "Install log rotate script" | |
| task :rotate_logs, :roles => :app do | |
| set :use_sudo, true | |
| default_run_options[:pty] = true | |
| rotate_script = %Q{#{shared_path}/log/*.log { | |
| daily | |
| missingok | |
| rotate 30 | |
| compress | |
| size 5M | |
| delaycompress | |
| sharedscripts | |
| postrotate | |
| touch #{current_path}/tmp/restart.txt | |
| endscript | |
| }} | |
| put rotate_script, "#{shared_path}/logrotate_script" | |
| sudo "cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}_#{rails_env}" | |
| run "rm #{shared_path}/logrotate_script" | |
| # run manually with: logrotate -f /etc/logrotate.d/homesav_staging | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am assuming you're restarting Passenger because the logfiles are not being freed up. You can use the
copytruncateparameter in the rotate script and you shouldn't have to worry about bouncing it.