views:

67

answers:

1

I've configured my Rails 2.3.8 logger in the environment.rb to rotate daily:

config.logger = Logger.new("#{RAILS_ROOT}/logs/#{RAILS_ENV}.log", 'daily')

and every day in the morning I get the usual:

Error during failsafe response: Shifting failed.

Is there a decent/elegant/better solution to this?

What I've done in the past is just set up a cron job to notice when this happens and to drop a Passenger restart.txt file in the app's tmp/ directory.

Thanks.

A: 

It's pretty common on UNIX/Linux to use a program named logrotate to perform log file rotation. Slicehost have a couple of nice articles on how to use it.

For a Phusion Passenger deployment you can use a configuration like the example below. Obviously adjust the directories and rotation frequency as appropriate.

/home/deploy/public_html/railsapp/shared/log/*.log {
  weekly
  missingok
  rotate 30
  compress
  delaycompress
  notifempty
  sharedscripts
  postrotate
    touch /home/deploy/public_html/railsapp/current/tmp/restart.txt
  endscript
}
John Topley
Thanks, I'll check that out.
Amy
Yep. That worked! Some notes in the form of a blog post:http://blog.seqmedia.com/?p=216
Amy