Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # log rotatation
- #
- # script/runner & cron で実行する
- SERVER_PID = configatron.server.pid
- ACCESS_LOG = configatron.server.access_log
- ACCESS_LOG_STRFTIME = configatron.server.access_log_strftime
- RAILS_LOG = configatron.server.rails_log
- RAILS_LOG_STRFTIME = configatron.server.rails_log_strftime
- File.umask(0000)
- pid = File.read(SERVER_PID).to_i rescue nil
- def rotate(src, dst)
- if FileTest.exist?(src)
- if !FileTest.exist?(dst)
- File.rename(src, dst)
- end
- end
- end
- rotate(ACCESS_LOG, 1.day.ago.strftime(ACCESS_LOG_STRFTIME))
- rotate(RAILS_LOG, 1.day.ago.strftime(RAILS_LOG_STRFTIME))
- Process.kill(:USR1, pid) if pid
- system("touch", "#{RAILS_ROOT}/tmp/restart.txt")
Add Comment
Please, Sign In to add comment