ミドルウェアにPassengerを利用してRailsアプリをホストしている場合、ログのサイズには要注意。いや、これはあらゆるログそうなんですけど、そのまま放置するとproduction.logが無限に増大するなんてアレな感じになる。そこで通常のログと同様logrotateを利用するのは同様なのだけど、postrotate
で touch restart.txt
するのがポイント。
こんな感じ。
# /etc/logrotate.d/passenger.log
/path/to/app/shared/log/*log {
notifempty
daily
missingok
rotate 3650
compress
delaycompress
sharedscripts
create 0644 apache-user apache-group
dateext
postrotate
touch /path/to/app/current/tmp/restart.txt
endscript
}
rotateアノテーションを忘れるとログが消えちゃうので注意。/path/to/app
の辺りは当然ながらアプリケーションのパスに書き換えること。