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 ju开发者_如何学运维st 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.
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 }
If you have many requests coming in simultaneously, and it is time for the Rails to rotate logs. If a stream is trying to write to a file ( the logger.rb code has a line that says : @dev.stat.size) and when the file does not exist (because it is being rotated) then it throws a fatal exception, and basically the server stops responding to requests (it doesn’t necessarily shut down, but bombs out on requests.
精彩评论