Log rotation for passenger applications
So I was given the arduous task of creating a log rotation script for our ~150 passenger applications.
A couple of people pointed me in a direction of editing the logger settings via the applications environment.rb. In my mind I was yelling, Hell no. I’m not editing over 150 sites just for log rotation.
Logrotate came to my rescue:
$ cat /etc/logrotate.d/passenger
/home/deploy/apps/*/current/log/production.log {
daily
missingok
rotate 30
compress
delaycompress
su deploy deploy #Updated 2/9/13 If the folder is not root, add this line
create 0666 deploy deploy
sharedscripts
postrotate
touch /home/deploy/apps/*/current/tmp/restart.txt
endscript
}
For SCIENCE purposes here is how to use the built in logger, but i highly advise against using it.
config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 5, 10.megabytes)